Patch by Paul <pdemarco@zoominternet.net> and Colin Ogilvie <colin.ogilvie@gmail.com>; r/a=justdave
trim wrap_comment find_wrap_point
format_time format_time_decimal
file_mod_time
- bz_crypt);
+ bz_crypt clean_text);
use Bugzilla::Config;
use Bugzilla::Error;
}
}
+sub clean_text {
+ my ($dtext) = shift;
+ $dtext =~ s/[\x00-\x1F\x7F]+/ /g; # change control characters to a space
+ return trim($dtext);
+}
+
1;
__END__
Please always use this function instead of the built-in perl "crypt"
when initially encrypting a password.
+=item C<clean_text($str)>
+Returns the parameter "cleaned" by exchanging non-printable characters with a space.
+Specifically characters (ASCII 0 through 31) and (ASCII 127) will become ASCII 32 (Space).
+
=begin undocumented
Random salts are generated because the alternative is usually
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' " . $dbh->sql_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.
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");
}
CheckFormFieldDefined($cgi, 'bug_file_loc');
CheckFormFieldDefined($cgi, 'short_desc');
CheckFormFieldDefined($cgi, 'longdesclength');
+ $cgi->param('short_desc', clean_text($cgi->param('short_desc')));
if (trim($cgi->param('short_desc')) eq "") {
ThrowUserError("require_summary");