From 5c5b0ddaffee9046732abc3abc723adc2c4a9ee4 Mon Sep 17 00:00:00 2001
From: ryan <ryan@1a063a9b-81f0-0310-95a4-ce76da25c4cd>
Date: Tue, 24 Nov 2009 14:40:25 +0000
Subject: [PATCH] Filter imported comments

git-svn-id: http://svn.automattic.com/wordpress/trunk@12270 1a063a9b-81f0-0310-95a4-ce76da25c4cd
---
 wp-admin/import/blogger.php     |  1 +
 wp-admin/import/dotclear.php    | 45 +++++++++++++--------------------
 wp-admin/import/livejournal.php |  1 +
 wp-admin/import/textpattern.php | 41 ++++++++++++------------------
 4 files changed, 35 insertions(+), 53 deletions(-)

diff --git a/wp-admin/import/blogger.php b/wp-admin/import/blogger.php
index 8b25c8f0cd..58aa684bc2 100644
--- a/wp-admin/import/blogger.php
+++ b/wp-admin/import/blogger.php
@@ -622,6 +622,7 @@ class Blogger_Import {
 		} else {
 			$comment = compact('comment_post_ID', 'comment_author', 'comment_author_url', 'comment_date', 'comment_content');
 
+			$comment = wp_filter_comment($comment);
 			$comment_id = wp_insert_comment($comment);
 
 			$this->blogs[$importing_blog]['comments'][$entry->old_permalink] = $comment_id;
diff --git a/wp-admin/import/dotclear.php b/wp-admin/import/dotclear.php
index 2e093354ac..fcde9b1773 100644
--- a/wp-admin/import/dotclear.php
+++ b/wp-admin/import/dotclear.php
@@ -413,36 +413,25 @@ class Dotclear_Import {
 				$web = "http://".$wpdb->escape($comment_site);
 				$message = $wpdb->escape(textconv ($comment_content));
 
-				if($cinfo = comment_exists($name, $comment_dt))
-				{
+				$comment = array(
+							'comment_post_ID'	=> $comment_post_ID,
+							'comment_author'	=> $name,
+							'comment_author_email'	=> $email,
+							'comment_author_url'	=> $web,
+							'comment_author_IP'	=> $comment_ip,
+							'comment_date'		=> $comment_dt,
+							'comment_date_gmt'	=> $comment_dt,
+							'comment_content'	=> $message,
+							'comment_approved'	=> $comment_approved);
+				$comment = wp_filter_comment($comment);
+
+				if ( $cinfo = comment_exists($name, $comment_dt) ) {
 					// Update comments
-					$ret_id = wp_update_comment(array(
-							'comment_ID'		=> $cinfo,
-							'comment_post_ID'	=> $comment_post_ID,
-							'comment_author'	=> $name,
-							'comment_author_email'	=> $email,
-							'comment_author_url'	=> $web,
-							'comment_author_IP'	=> $comment_ip,
-							'comment_date'		=> $comment_dt,
-							'comment_date_gmt'	=> $comment_dt,
-							'comment_content'	=> $message,
-							'comment_approved'	=> $comment_approved)
-							);
-				}
-				else
-				{
+					$comment['comment_ID'] = $cinfo;
+					$ret_id = wp_update_comment($comment);
+				} else {
 					// Insert comments
-					$ret_id = wp_insert_comment(array(
-							'comment_post_ID'	=> $comment_post_ID,
-							'comment_author'	=> $name,
-							'comment_author_email'	=> $email,
-							'comment_author_url'	=> $web,
-							'comment_author_IP'	=> $comment_ip,
-							'comment_date'		=> $comment_dt,
-							'comment_date_gmt'	=> $comment_dt,
-							'comment_content'	=> $message,
-							'comment_approved'	=> $comment_approved)
-							);
+					$ret_id = wp_insert_comment($comment);
 				}
 				$dccm2wpcm[$comment_ID] = $ret_id;
 			}
diff --git a/wp-admin/import/livejournal.php b/wp-admin/import/livejournal.php
index e7efee1b17..7acfaa5fee 100644
--- a/wp-admin/import/livejournal.php
+++ b/wp-admin/import/livejournal.php
@@ -535,6 +535,7 @@ class LJ_API_Import {
 
 				// Parse this comment into an array and insert
 				$comment = $this->parse_comment( $comment );
+				$comment = wp_filter_comment( $comment );
 				$id = wp_insert_comment( $comment );
 
 				// Clear cache
diff --git a/wp-admin/import/textpattern.php b/wp-admin/import/textpattern.php
index bf4f04faa8..fb47213935 100644
--- a/wp-admin/import/textpattern.php
+++ b/wp-admin/import/textpattern.php
@@ -397,33 +397,24 @@ class Textpattern_Import {
 				$web = $wpdb->escape($web);
 				$message = $wpdb->escape($message);
 
-				if($cinfo = comment_exists($name, $posted))
-				{
+				$comment = array(
+							'comment_post_ID'	=> $comment_post_ID,
+							'comment_author'	=> $name,
+							'comment_author_IP'	=> $ip,
+							'comment_author_email'	=> $email,
+							'comment_author_url'	=> $web,
+							'comment_date'		=> $posted,
+							'comment_content'	=> $message,
+							'comment_approved'	=> $comment_approved);
+				$comment = wp_filter_comment($comment);
+
+				if ( $cinfo = comment_exists($name, $posted) ) {
 					// Update comments
-					$ret_id = wp_update_comment(array(
-						'comment_ID'			=> $cinfo,
-						'comment_post_ID'		=> $comment_post_ID,
-						'comment_author'		=> $name,
-						'comment_author_email'	=> $email,
-						'comment_author_url'	=> $web,
-						'comment_date'			=> $posted,
-						'comment_content'		=> $message,
-						'comment_approved'		=> $comment_approved)
-						);
-				}
-				else
-				{
+					$comment['comment_ID'] = $cinfo;
+					$ret_id = wp_update_comment($comment);
+				} else {
 					// Insert comments
-					$ret_id = wp_insert_comment(array(
-						'comment_post_ID'		=> $comment_post_ID,
-						'comment_author'		=> $name,
-						'comment_author_email'	=> $email,
-						'comment_author_url'	=> $web,
-						'comment_author_IP'		=> $ip,
-						'comment_date'			=> $posted,
-						'comment_content'		=> $message,
-						'comment_approved'		=> $comment_approved)
-						);
+					$ret_id = wp_insert_comment($comment);
 				}
 				$txpcm2wpcm[$comment_ID] = $ret_id;
 			}