gitweb: fix error in sanitize when highlight is enabled

$1 becomes undef by internal regex, since it has no capture groups.

Match against accpetable control characters using index() instead of a regex.

Signed-off-by: Orgad Shaneh <orgads@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Orgad Shaneh 2012-12-30 13:52:53 +02:00 committed by Junio C Hamano
parent d0f1ea6003
commit 0e901d24fd

View file

@ -1538,7 +1538,7 @@ sub sanitize {
return undef unless defined $str;
$str = to_utf8($str);
$str =~ s|([[:cntrl:]])|($1 =~ /[\t\n\r]/ ? $1 : quot_cec($1))|eg;
$str =~ s|([[:cntrl:]])|(index("\t\n\r", $1) != -1 ? $1 : quot_cec($1))|eg;
return $str;
}