]> 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:52:07 +0000 (03:52 +0000)
committermozilla%colinogilvie.co.uk <>
Mon, 9 Jan 2006 03:52:07 +0000 (03:52 +0000)
Patch by Paul <pdemarco@zoominternet.net> and Colin Ogilvie <colin.ogilvie@gmail.com>; r/a=justdave

checksetup.pl
globals.pl
post_bug.cgi
process_bug.cgi

index c74a760c041d37633024865103554f651353e4bb..4e5395a7668bf75a2400dd8f676550cda28d85d0 100755 (executable)
@@ -3010,6 +3010,25 @@ if (GetFieldDef("logincookies", "hostname")) {
     AddField("logincookies", "ipaddr", "varchar(40) NOT NULL");
 }
 
+# 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 " .
+                             "'short_desc' REGEXP '[[: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 fc3764e5616a9c5084c78b8b0f87805306ebf876..1bb80d70b3f3e231d67097be7a5142911bc1683d 100644 (file)
@@ -1574,6 +1574,12 @@ sub trim {
     return $str;
 }
 
+sub clean_text {
+    my ($dtext) = shift;
+    $dtext =~  s/[\x00-\x1F\x7F]+/ /g;   # change control characters to spaces
+    return trim($dtext);
+}
+
 ###############################################################################
 # Global Templatization Code
 
index 10c3fb5e857c2b3e7f74877b9e8d9aaabe943030..0f4267e7abe8f5a1db5b0926027b86669bd33d3c 100755 (executable)
@@ -100,7 +100,8 @@ if (!$::FORM{'component'}) {
     exit;                  
 }
 
-if (!defined $::FORM{'short_desc'} || trim($::FORM{'short_desc'}) eq "") {
+$::FORM{'short_desc'} = clean_text($::FORM{'short_desc'});
+if (!defined $::FORM{'short_desc'} || $::FORM{'short_desc'} eq "") {
     DisplayError("You must enter a summary for this bug.");
     exit;
 }
index 07b93129e09c126dbcb1b597f4086f213e831222..e1d37c0e5bf31feeac7d341b0bbfcfc1cddcb50a 100755 (executable)
@@ -125,6 +125,8 @@ if ( Param("usetargetmilestone") ) {
   CheckFormFieldDefined(\%::FORM, 'target_milestone');
 }
 
+$::FORM{'short_desc'} = clean_text($::FORM{'short_desc'});
+
 #
 # This function checks if there is a comment required for a specific
 # function and tests, if the comment was given.