Skip to content

Commit 0efd713

Browse files
katsusanearl-warren
authored andcommitted
fix trailing comma not matched in the case of alphanumeric issue (go-gitea#32945)
Fix go-gitea#32428. Patch the regex to match `,`besides `.` `"` `'` `:` and space. (cherry picked from commit fb75151)
1 parent 234b57b commit 0efd713

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

modules/references/references.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ var (
3232
// issueNumericPattern matches string that references to a numeric issue, e.g. #1287
3333
issueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\'|\")([#!][0-9]+)(?:\s|$|\)|\]|\'|\"|[:;,.?!]\s|[:;,.?!]$)`)
3434
// issueAlphanumericPattern matches string that references to an alphanumeric issue, e.g. ABC-1234
35-
issueAlphanumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\"|\')([A-Z]{1,10}-[1-9][0-9]*)(?:\s|$|\)|\]|:|\.(\s|$)|\"|\')`)
35+
issueAlphanumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[|\"|\')([A-Z]{1,10}-[1-9][0-9]*)(?:\s|$|\)|\]|:|\.(\s|$)|\"|\'|,)`)
3636
// crossReferenceIssueNumericPattern matches string that references a numeric issue in a different repository
3737
// e.g. org/repo#12345
3838
crossReferenceIssueNumericPattern = regexp.MustCompile(`(?:\s|^|\(|\[)([0-9a-zA-Z-_\.]+/[0-9a-zA-Z-_\.]+[#!][0-9]+)(?:\s|$|\)|\]|[:;,.?!]\s|[:;,.?!]$)`)

modules/references/references_test.go

+1
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,7 @@ func TestRegExp_issueAlphanumericPattern(t *testing.T) {
466466
"ABC-123:",
467467
"\"ABC-123\"",
468468
"'ABC-123'",
469+
"ABC-123, unknown PR",
469470
}
470471
falseTestCases := []string{
471472
"RC-08",

0 commit comments

Comments
 (0)