aboutsummaryrefslogtreecommitdiffstats
path: root/modules
diff options
context:
space:
mode:
authorGiteabot <teabot@gitea.io>2024-12-23 06:08:35 +0800
committerGitHub <noreply@github.com>2024-12-23 06:08:35 +0800
commita8f98fd3be059c484fcee4d8e320f62059eea026 (patch)
treea64b9c5f4179664f36bb0a5c1b6a8919a16134fd /modules
parentc442c682ef57f83115593d72541f314da464b2dc (diff)
downloadgitea-a8f98fd3be059c484fcee4d8e320f62059eea026.tar.gz
gitea-a8f98fd3be059c484fcee4d8e320f62059eea026.zip
fix trailing comma not matched in the case of alphanumeric issue (#32945) (#32959)
Backport #32945 by @katsusan Fix #32428. Patch the regex to match `,`besides `.` `"` `'` `:` and space. Co-authored-by: katsu <evergonuaa@gmail.com>
Diffstat (limited to 'modules')
-rw-r--r--modules/references/references.go2
-rw-r--r--modules/references/references_test.go1
2 files changed, 2 insertions, 1 deletions
diff --git a/modules/references/references.go b/modules/references/references.go
index 6e549cb875..dcb70a33d0 100644
--- a/modules/references/references.go
+++ b/modules/references/references.go
@@ -32,7 +32,7 @@ var (
// 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
- issueAlphanumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\"|\')([A-Z]{1,10}-[1-9][0-9]*)(?:\s|$|\)|\]|:|\.(\s|$)|\"|\')`)
+ issueAlphanumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\"|\')([A-Z]{1,10}-[1-9][0-9]*)(?:\s|$|\)|\]|:|\.(\s|$)|\"|\'|,)`)
// crossReferenceIssueNumericPattern matches string that references a numeric issue in a different repository
// e.g. org/repo#12345
crossReferenceIssueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-zA-Z-_\.]+/[0-9a-zA-Z-_\.]+[#!][0-9]+)(?:\s|$|\)|\]|[:;,.?!]\s|[:;,.?!]$)`)
diff --git a/modules/references/references_test.go b/modules/references/references_test.go
index e224c919e9..27803083c0 100644
--- a/modules/references/references_test.go
+++ b/modules/references/references_test.go
@@ -463,6 +463,7 @@ func TestRegExp_issueAlphanumericPattern(t *testing.T) {
"ABC-123:",
"\"ABC-123\"",
"'ABC-123'",
+ "ABC-123, unknown PR",
}
falseTestCases := []string{
"RC-08",