Index: wp-includes/post.php
===================================================================
--- wp-includes/post.php	(revision 19480)
+++ wp-includes/post.php	(working copy)
@@ -2412,7 +2412,7 @@
  * @param bool $wp_error Optional. Allow return of WP_Error on failure.
  * @return int|WP_Error The value 0 or WP_Error on failure. The post ID on success.
  */
-function wp_insert_post($postarr, $wp_error = false) {
+function wp_insert_post($postarr, $wp_error = false, $sanitize = true) {
 	global $wpdb, $wp_rewrite, $user_ID;
 
 	$defaults = array('post_status' => 'draft', 'post_type' => 'post', 'post_author' => $user_ID,
@@ -2425,7 +2425,9 @@
 
 	unset( $postarr[ 'filter' ] );
 
-	$postarr = sanitize_post($postarr, 'db');
+	if ( $sanitize ) {
+		$postarr = sanitize_post($postarr, 'db');
+	}
 
 	// export array as variables
 	extract($postarr, EXTR_SKIP);
@@ -2479,7 +2481,7 @@
 	}
 
 	// Don't allow contributors to set the post slug for pending review posts
-	if ( 'pending' == $post_status && !current_user_can( 'publish_posts' ) )
+	if ( 'pending' == $post_status && $sanitize && !current_user_can( 'publish_posts' ) )
 		$post_name = '';
 
 	// Create a valid post name.  Drafts and pending posts are allowed to have an empty
@@ -2615,7 +2617,7 @@
 			$taxonomy_obj = get_taxonomy($taxonomy);
 			if ( is_array($tags) ) // array = hierarchical, string = non-hierarchical.
 				$tags = array_filter($tags);
-			if ( current_user_can($taxonomy_obj->cap->assign_terms) )
+			if ( !$sanitize || current_user_can($taxonomy_obj->cap->assign_terms) )
 				wp_set_post_terms( $post_ID, $tags, $taxonomy );
 		}
 	}
