Merge branch 'da/difftool-dir-diff-fix' into maint
[gitweb.git] / gitweb / gitweb.perl
index 44094f41d580bd4259bdb2bdb680b6dff4fd5340..7cf68f07b773f7e520c1e6ba680bff65e5bc7f3a 100755 (executable)
@@ -1616,7 +1616,7 @@ sub esc_path {
        return $str;
 }
 
-# Sanitize for use in XHTML + application/xml+xhtm (valid XML 1.0)
+# Sanitize for use in XHTML + application/xml+xhtml (valid XML 1.0)
 sub sanitize {
        my $str = shift;
 
@@ -2036,10 +2036,24 @@ sub format_log_line_html {
        my $line = shift;
 
        $line = esc_html($line, -nbsp=>1);
-       $line =~ s{\b([0-9a-fA-F]{8,40})\b}{
+       $line =~ s{
+        \b
+        (
+            # The output of "git describe", e.g. v2.10.0-297-gf6727b0
+            # or hadoop-20160921-113441-20-g094fb7d
+            (?<!-) # see strbuf_check_tag_ref(). Tags can't start with -
+            [A-Za-z0-9.-]+
+            (?!\.) # refs can't end with ".", see check_refname_format()
+            -g[0-9a-fA-F]{7,40}
+            |
+            # Just a normal looking Git SHA1
+            [0-9a-fA-F]{7,40}
+        )
+        \b
+    }{
                $cgi->a({-href => href(action=>"object", hash=>$1),
                                        -class => "text"}, $1);
-       }eg;
+       }egx;
 
        return $line;
 }