]> Lady’s Gitweb - Gitweb/commitdiff
gitweb: Better regexp for SHA-1 committag match
authorJakub Narebski <redacted>
Fri, 6 Feb 2009 09:12:41 +0000 (10:12 +0100)
committerLady <redacted>
Mon, 6 Apr 2026 04:50:38 +0000 (00:50 -0400)
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 <redacted>
Signed-off-by: Jakub Narebski <redacted>
Signed-off-by: Junio C Hamano <redacted>
gitweb.perl

index 10f679d2e1bdcab2d405a0a2bf5715b337ed85c8f3d5aabb026bf97bf929c9b1..913edb168767bc7e618396a91f94e31afd03455defc5ea145d6c2a8fe7f4475e 100755 (executable)
@@ -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),
This page took 0.202847 seconds and 4 git commands to generate.