Index: wp-includes/taxonomy.php
===================================================================
--- wp-includes/taxonomy.php	(revision 21527)
+++ wp-includes/taxonomy.php	(working copy)
@@ -328,6 +328,11 @@
 					);
 	$args = wp_parse_args($args, $defaults);
 
+	$taxonomy = sanitize_key( $taxonomy );
+
+	if ( strlen( $taxonomy ) > 32 )
+		return new WP_Error( 'taxonomy_too_long', __( 'Taxonomies cannot exceed 32 characters in length' ) );
+
 	if ( false !== $args['query_var'] && !empty($wp) ) {
 		if ( true === $args['query_var'] )
 			$args['query_var'] = $taxonomy;
@@ -380,7 +385,7 @@
 	$wp_taxonomies[$taxonomy] = (object) $args;
 
 	// register callback handling for metabox
- 	add_filter('wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term');
+	add_filter('wp_ajax_add-' . $taxonomy, '_wp_ajax_add_hierarchical_term');
 
 	do_action( 'registered_taxonomy', $taxonomy, $object_type, $args );
 }
Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 21527)
+++ wp-includes/post.php	(working copy)
@@ -989,11 +989,12 @@
 	$args = (object) $args;
 
 	$post_type = sanitize_key($post_type);
-	$args->name = $post_type;
 
 	if ( strlen( $post_type ) > 20 )
-			return new WP_Error( 'post_type_too_long', __( 'Post types cannot exceed 20 characters in length' ) );
+		return new WP_Error( 'post_type_too_long', __( 'Post types cannot exceed 20 characters in length' ) );
 
+	$args->name = $post_type;
+
 	// If not set, default to the setting for public.
 	if ( null === $args->publicly_queryable )
 		$args->publicly_queryable = $args->public;
