Patch by Paul <pdemarco@zoominternet.net> and Colin Ogilvie <colin.ogilvie@gmail.com>; r/a=justdave
html_quote url_quote value_quote xml_quote
css_class_quote
lsearch max min
- trim format_time);
+ trim format_time clean_text);
use Bugzilla::Config;
return $time;
}
+sub clean_text {
+ my ($dtext) = shift;
+ $dtext =~ s/[\x00-\x1F\x7F]+/ /g; # change control characters to a space
+ return trim($dtext);
+}
+
1;
__END__
Removes any leading or trailing whitespace from a string. This routine does not
modify the existing string.
+=item C<clean_text($str)>
+Returns the parameter "cleaned" by exchanging non-printable characters with spaces.
+Specifically characters (ASCII 0 through 31) and (ASCII 127) will become ASCII 32 (Space).
+
=back
=head2 Formatting Time
print " done.\n";
}
+# 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.
my $component_id = get_component_id($product_id, $::FORM{component});
$component_id || ThrowUserError("require_component");
-if (!defined $::FORM{'short_desc'} || trim($::FORM{'short_desc'}) eq "") {
+# Set the parameter to itself, but cleaned up
+$::FORM{'short_desc'} = clean_text($::FORM{'short_desc'});
+
+if (!defined $::FORM{'short_desc'} || $::FORM{'short_desc'} eq "") {
ThrowUserError("require_summary");
}
CheckFormFieldDefined(\%::FORM, 'bug_file_loc');
CheckFormFieldDefined(\%::FORM, 'short_desc');
CheckFormFieldDefined(\%::FORM, 'longdesclength');
+ $::FORM{'short_desc'} = clean_text($::FORM{'short_desc'});
if (trim($::FORM{'short_desc'}) eq "") {
ThrowUserError("require_summary");