diff --git a/modules/markup/html.go b/modules/markup/html.go index 7ac23d05038..9e4b1a3d5d3 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -43,7 +43,7 @@ var ( // sha1CurrentPattern matches string that represents a commit SHA, e.g. d8a994ef243349f321568f9e36d5c3f444b99cae // Although SHA1 hashes are 40 chars long, the regex matches the hash from 7 to 40 chars in length // so that abbreviated hash links can be used as well. This matches git and github useability. - sha1CurrentPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-f]{7,40})(?:\s|$|\)|\]|\.(\s|$))`) + sha1CurrentPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-f]{7,40})(?:\s|$|\)|\]|[.,](\s|$))`) // shortLinkPattern matches short but difficult to parse [[name|link|arg=test]] syntax shortLinkPattern = regexp.MustCompile(`\[\[(.*?)\]\](\w*)`) diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index a3c273e628d..b04781489a8 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -46,6 +46,12 @@ func TestRender_Commits(t *testing.T) { test("/home/gitea/"+sha, "
/home/gitea/"+sha+"
") test("deadbeef", `deadbeef
`) test("d27ace93", `d27ace93
`) + test(sha[:14]+".x", ``+sha[:14]+`.x
`) + + expected14 := `` + sha[:10] + `
`
+ test(sha[:14]+".", ``+expected14+`.
`) + test(sha[:14]+",", ``+expected14+`,
`) + test("["+sha[:14]+"]", `[`+expected14+`]
`) } func TestRender_CrossReferences(t *testing.T) {