Skip to content

Commit 0710498

Browse files
lunnyGiteaBot
authored andcommitted
Fix hash render end with colon (go-gitea#31319)
Fix a hash render problem like `<hash>: xxxxx` which is usually used in release notes.
1 parent 568ff10 commit 0710498

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

modules/markup/html.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ var (
4949
// hashCurrentPattern matches string that represents a commit SHA, e.g. d8a994ef243349f321568f9e36d5c3f444b99cae
5050
// Although SHA1 hashes are 40 chars long, SHA256 are 64, the regex matches the hash from 7 to 64 chars in length
5151
// so that abbreviated hash links can be used as well. This matches git and GitHub usability.
52-
hashCurrentPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-f]{7,64})(?:\s|$|\)|\]|[.,](\s|$))`)
52+
hashCurrentPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-f]{7,64})(?:\s|$|\)|\]|[.,:](\s|$))`)
5353

5454
// shortLinkPattern matches short but difficult to parse [[name|link|arg=test]] syntax
5555
shortLinkPattern = regexp.MustCompile(`\[\[(.*?)\]\](\w*)`)

modules/markup/html_internal_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -380,6 +380,7 @@ func TestRegExp_sha1CurrentPattern(t *testing.T) {
380380
"(abcdefabcdefabcdefabcdefabcdefabcdefabcd)",
381381
"[abcdefabcdefabcdefabcdefabcdefabcdefabcd]",
382382
"abcdefabcdefabcdefabcdefabcdefabcdefabcd.",
383+
"abcdefabcdefabcdefabcdefabcdefabcdefabcd:",
383384
}
384385
falseTestCases := []string{
385386
"test",

0 commit comments

Comments
 (0)