aboutsummaryrefslogtreecommitdiffstats
path: root/modules/markup
diff options
context:
space:
mode:
authorLunny Xiao <xiaolunwen@gmail.com>2024-06-13 06:35:46 +0800
committerGitHub <noreply@github.com>2024-06-12 22:35:46 +0000
commit7115dce773e3021b3538ae360c4e7344d5bbf45b (patch)
tree6a942bd2b53d729da42416fae8cbc82a458e8208 /modules/markup
parent90bcdf9829ebc4ce1636f887cd2b032046078d9c (diff)
downloadgitea-7115dce773e3021b3538ae360c4e7344d5bbf45b.tar.gz
gitea-7115dce773e3021b3538ae360c4e7344d5bbf45b.zip
Fix hash render end with colon (#31319)
Fix a hash render problem like `<hash>: xxxxx` which is usually used in release notes.
Diffstat (limited to 'modules/markup')
-rw-r--r--modules/markup/html.go2
-rw-r--r--modules/markup/html_internal_test.go1
2 files changed, 2 insertions, 1 deletions
diff --git a/modules/markup/html.go b/modules/markup/html.go
index 8dbc958299..565bc175b7 100644
--- a/modules/markup/html.go
+++ b/modules/markup/html.go
@@ -49,7 +49,7 @@ var (
// hashCurrentPattern matches string that represents a commit SHA, e.g. d8a994ef243349f321568f9e36d5c3f444b99cae
// Although SHA1 hashes are 40 chars long, SHA256 are 64, the regex matches the hash from 7 to 64 chars in length
// so that abbreviated hash links can be used as well. This matches git and GitHub usability.
- hashCurrentPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-f]{7,64})(?:\s|$|\)|\]|[.,](\s|$))`)
+ hashCurrentPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-f]{7,64})(?:\s|$|\)|\]|[.,:](\s|$))`)
// shortLinkPattern matches short but difficult to parse [[name|link|arg=test]] syntax
shortLinkPattern = regexp.MustCompile(`\[\[(.*?)\]\](\w*)`)
diff --git a/modules/markup/html_internal_test.go b/modules/markup/html_internal_test.go
index 9aa9c22d70..74089cffdd 100644
--- a/modules/markup/html_internal_test.go
+++ b/modules/markup/html_internal_test.go
@@ -380,6 +380,7 @@ func TestRegExp_sha1CurrentPattern(t *testing.T) {
"(abcdefabcdefabcdefabcdefabcdefabcdefabcd)",
"[abcdefabcdefabcdefabcdefabcdefabcdefabcd]",
"abcdefabcdefabcdefabcdefabcdefabcdefabcd.",
+ "abcdefabcdefabcdefabcdefabcdefabcdefabcd:",
}
falseTestCases := []string{
"test",