Index: wordpress-importer.php
===================================================================
--- wordpress-importer.php	(revision 461346)
+++ wordpress-importer.php	(working copy)
@@ -950,14 +950,25 @@
 	 */
 	function backfill_attachment_urls() {
 		global $wpdb;
-		// make sure we do the longest urls first, in case one is a substring of another
-		uksort( $this->url_remap, array(&$this, 'cmpr_strlen') );
-
+		$replacements = $post_contents = array();
 		foreach ( $this->url_remap as $from_url => $to_url ) {
-			// remap urls in post_content
-			$wpdb->query( $wpdb->prepare("UPDATE {$wpdb->posts} SET post_content = REPLACE(post_content, %s, %s)", $from_url, $to_url) );
-			// remap enclosure urls
 			$result = $wpdb->query( $wpdb->prepare("UPDATE {$wpdb->postmeta} SET meta_value = REPLACE(meta_value, %s, %s) WHERE meta_key='enclosure'", $from_url, $to_url) );
+			
+			$posts = $wpdb->get_results( $wpdb->prepare( "SELECT ID, post_content FROM {$wpdb->posts} WHERE post_content LIKE %s", '%' . like_escape( $from_url ) . '%' ) );
+			if ( count( $posts ) >  0 ) {
+				foreach ( $posts as $post ) {
+					$replacements[$post->ID][$from_url] = $to_url;
+					$post_contents[$post->ID] = $post->post_content;
+				}
+			}
+			unset( $posts );
+		}
+		foreach( $replacements as $post_id => $post_replacements ) {
+			// make sure we do the longest urls first, in case one is a substring of another
+			uksort( $post_replacements, array(&$this, 'cmpr_strlen') );
+			$new_post_content = str_replace( array_keys( $post_replacements ), array_values( $post_replacements ), $post_contents[$post_id] );
+			if ( $new_post_content <> $post_contents[$post_id] )
+				$wpdb->update( $wpdb->posts, array( 'post_content' => $new_post_content ), array( 'ID' => $post_id ) );
 		}
 	}
 
