diff options
author | wxiaoguang <wxiaoguang@gmail.com> | 2024-05-02 09:00:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-02 01:00:46 +0000 |
commit | ce08a9fe2f7c9ae6390f1ad3d619524010a4e787 (patch) | |
tree | c831fee12cdf0104a7864e9ac37c9d492b4254e8 /modules/references | |
parent | 6f7cd94a02aaf14bf2e2a6219bbc4379c4995b5d (diff) | |
download | gitea-ce08a9fe2f7c9ae6390f1ad3d619524010a4e787.tar.gz gitea-ce08a9fe2f7c9ae6390f1ad3d619524010a4e787.zip |
Fix markdown rendering when mentioning users (#30795)
Diffstat (limited to 'modules/references')
-rw-r--r-- | modules/references/references.go | 2 | ||||
-rw-r--r-- | modules/references/references_test.go | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/modules/references/references.go b/modules/references/references.go index 761d6ee3d1..1b656ed4cb 100644 --- a/modules/references/references.go +++ b/modules/references/references.go @@ -29,7 +29,7 @@ var ( // TODO: fix invalid linking issue // mentionPattern matches all mentions in the form of "@user" or "@org/team" - mentionPattern = regexp.MustCompile(`(?:\s|^|\(|\[)(@[0-9a-zA-Z-_]+|@[0-9a-zA-Z-_]+\/?[0-9a-zA-Z-_]+|@[0-9a-zA-Z-_][0-9a-zA-Z-_.]+\/?[0-9a-zA-Z-_.]+[0-9a-zA-Z-_])(?:\s|[:,;.?!]\s|[:,;.?!]?$|\)|\])`) + mentionPattern = regexp.MustCompile(`(?:\s|^|\(|\[)(@[-\w][-.\w]*?|@[-\w][-.\w]*?/[-\w][-.\w]*?)(?:\s|$|[:,;.?!](\s|$)|'|\)|\])`) // issueNumericPattern matches string that references to a numeric issue, e.g. #1287 issueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\'|\")([#!][0-9]+)(?:\s|$|\)|\]|\'|\"|[:;,.?!]\s|[:;,.?!]$)`) // issueAlphanumericPattern matches string that references to an alphanumeric issue, e.g. ABC-1234 diff --git a/modules/references/references_test.go b/modules/references/references_test.go index 0c32933619..e5a0d60fe3 100644 --- a/modules/references/references_test.go +++ b/modules/references/references_test.go @@ -392,6 +392,7 @@ func TestRegExp_mentionPattern(t *testing.T) { {"@gitea,", "@gitea"}, {"@gitea;", "@gitea"}, {"@gitea/team1;", "@gitea/team1"}, + {"@user's idea", "@user"}, } falseTestCases := []string{ "@ 0", @@ -412,7 +413,6 @@ func TestRegExp_mentionPattern(t *testing.T) { for _, testCase := range trueTestCases { found := mentionPattern.FindStringSubmatch(testCase.pat) - assert.Len(t, found, 2) assert.Equal(t, testCase.exp, found[1]) } for _, testCase := range falseTestCases { |