Skip to content

Commit

Permalink
gitweb: Better regexp for SHA-1 committag match
Browse files Browse the repository at this point in the history
Make SHA-1 regexp to be turned into hyperlink (the SHA-1 committag)
to match word boundary at the beginning and the end.  This way we
reduce number of false matches, for example we now don't match
0x74a5cd01 which is hex decimal (for example memory address),
but is not SHA-1.

Suggested-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Jakub Narebski <jnareb@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jakub Narebski authored and Junio C Hamano committed Feb 7, 2009
1 parent 621f1b4 commit ccb04f9
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion gitweb/gitweb.perl
Original file line number Diff line number Diff line change
Expand Up @@ -1364,7 +1364,7 @@ sub format_log_line_html {
my $line = shift;

$line = esc_html($line, -nbsp=>1);
if ($line =~ m/([0-9a-fA-F]{8,40})/) {
if ($line =~ m/\b([0-9a-fA-F]{8,40})\b/) {
my $hash_text = $1;
my $link =
$cgi->a({-href => href(action=>"object", hash=>$hash_text),
Expand Down

0 comments on commit ccb04f9

Please sign in to comment.