]> git.ipfire.org Git - thirdparty/bugzilla.git/commitdiff
Bug 101380: Newlines, nulls, leading/trailing spaces are getting into summaries
authormozilla%colinogilvie.co.uk <>
Mon, 9 Jan 2006 03:56:03 +0000 (03:56 +0000)
committermozilla%colinogilvie.co.uk <>
Mon, 9 Jan 2006 03:56:03 +0000 (03:56 +0000)
Patch by Paul <pdemarco@zoominternet.net> and Colin Ogilvie <colin.ogilvie@gmail.com>; r/a=justdave

Bugzilla/Util.pm
checksetup.pl
post_bug.cgi
process_bug.cgi

index 31a1052e43b03217b9b92426d845c93535f1d833..28f5e71bc324e33f40394d237fe6daf4baadef5d 100644 (file)
@@ -392,8 +392,8 @@ sub is_7bit_clean {
 
 sub clean_text {
     my ($dtext) = shift;
-    $dtext =~  s/[\x00-\x1F\x7F]/ /g;   # change control characters to spaces
-    return $dtext;
+    $dtext =~  s/[\x00-\x1F\x7F]+/ /g;   # change control characters into a space
+    return trim($dtext);
 }
 
 1;
index e8528aee1bb9010a8571af0154d30692acc05710..56db99b467ea308f79fa94ffae61cec73a6e9f98 100755 (executable)
@@ -4239,6 +4239,24 @@ $dbh->bz_alter_column('groups', 'userregexp',
 $dbh->bz_alter_column('logincookies', 'cookie',
                       {TYPE => 'varchar(16)', PRIMARYKEY => 1, NOTNULL => 1});
 
+# Fixup for Bug 101380
+# "Newlines, nulls, leading/trailing spaces are getting into summaries"
+
+my $controlchar_bugs =
+    $dbh->selectall_arrayref("SELECT short_desc, bug_id FROM bugs WHERE " .
+                             $dbh->sql_regexp('short_desc', "'[[:cntrl:]]'"));
+if (@$controlchar_bugs)
+{
+    print 'Cleaning control characters from bug summaries...';
+    foreach (@$controlchar_bugs) {
+        my ($short_desc, $bug_id) = @$_;
+        print " $bug_id...";
+        $short_desc = clean_text($short_desc);
+        $dbh->do("UPDATE bugs SET short_desc = ? WHERE bug_id = ?",
+                 undef, $short_desc, $bug_id);
+    }
+    print " done.\n";
+}
 
 # If you had to change the --TABLE-- definition in any way, then add your
 # differential change code *** A B O V E *** this comment.
index 3d2d6ab480a0050dc3304274cb4e7403efc760ed..4d8c6a2c9c2d7b32a18124a9f9a64f7c87afbf28 100755 (executable)
@@ -108,8 +108,11 @@ my $component_id = get_component_id($product_id,
                                     scalar($cgi->param('component')));
 $component_id || ThrowUserError("require_component");
 
+# Set the parameter to itself, but cleaned up
+$cgi->param('short_desc', clean_text($cgi->param('short_desc')));
+
 if (!defined $cgi->param('short_desc')
-    || trim($cgi->param('short_desc')) eq "") {
+    || $cgi->param('short_desc') eq "") {
     ThrowUserError("require_summary");
 }
 
index 77496f2a38952b5ef0dab3354b316becc4d49e64..79ad8e5177a544081642a63128c3aadf0d388c0d 100755 (executable)
@@ -611,6 +611,7 @@ if (defined $cgi->param('id')) {
     check_form_field_defined($cgi, 'bug_file_loc');
     check_form_field_defined($cgi, 'short_desc');
     check_form_field_defined($cgi, 'longdesclength');
+    $cgi->param('short_desc', clean_text($cgi->param('short_desc')));
 
     if (trim($cgi->param('short_desc')) eq "") {
         ThrowUserError("require_summary");