From: Jakub Narebski Date: Fri, 6 Feb 2009 09:12:41 +0000 (+0100) Subject: gitweb: Better regexp for SHA-1 committag match X-Git-Url: https://git.ladys.computer/Gitweb/commitdiff_plain/bb9db3a422e701cef902d1018a4ad87102f4711080b7e323995fdd9802d60884?hp=a02c806f06d5da1ec22dc5fab02fa8f8ee052d6d17ec4f9ac4c6fcd33380e5e6 gitweb: Better regexp for SHA-1 committag match 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 Signed-off-by: Jakub Narebski Signed-off-by: Junio C Hamano --- diff --git a/gitweb.perl b/gitweb.perl index 10f679d..913edb1 100755 --- a/gitweb.perl +++ b/gitweb.perl @@ -1365,7 +1365,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),