Skip to content

Commit e9e2a9c

Browse files
derkoelafriks
authored andcommitted
Allow square brackets in external issue patterns (#3408)
* Allow square brackets in external issue patterns * Added false test cases for checklist elements
1 parent e08b3a5 commit e9e2a9c

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

modules/markup/html.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ var (
3838
MentionPattern = regexp.MustCompile(`(\s|^|\W)@[0-9a-zA-Z-_\.]+`)
3939

4040
// IssueNumericPattern matches string that references to a numeric issue, e.g. #1287
41-
IssueNumericPattern = regexp.MustCompile(`( |^|\()#[0-9]+\b`)
41+
IssueNumericPattern = regexp.MustCompile(`( |^|\(|\[)#[0-9]+\b`)
4242
// IssueAlphanumericPattern matches string that references to an alphanumeric issue, e.g. ABC-1234
43-
IssueAlphanumericPattern = regexp.MustCompile(`( |^|\()[A-Z]{1,10}-[1-9][0-9]*\b`)
43+
IssueAlphanumericPattern = regexp.MustCompile(`( |^|\(|\[)[A-Z]{1,10}-[1-9][0-9]*\b`)
4444
// CrossReferenceIssueNumericPattern matches string that references a numeric issue in a different repository
4545
// e.g. gogits/gogs#12345
4646
CrossReferenceIssueNumericPattern = regexp.MustCompile(`( |^)[0-9a-zA-Z-_\.]+/[0-9a-zA-Z-_\.]+#[0-9]+\b`)

modules/markup/html_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ func TestRegExp_IssueNumericPattern(t *testing.T) {
345345
"#1234",
346346
"#0",
347347
"#1234567890987654321",
348+
"[#1234]",
348349
}
349350
falseTestCases := []string{
350351
"# 1234",
@@ -355,6 +356,8 @@ func TestRegExp_IssueNumericPattern(t *testing.T) {
355356
"#1A2B",
356357
"",
357358
"ABC",
359+
"[]",
360+
"[x]",
358361
}
359362

360363
for _, testCase := range trueTestCases {
@@ -371,6 +374,7 @@ func TestRegExp_IssueAlphanumericPattern(t *testing.T) {
371374
"A-1",
372375
"RC-80",
373376
"ABCDEFGHIJ-1234567890987654321234567890",
377+
"[JIRA-134]",
374378
}
375379
falseTestCases := []string{
376380
"RC-08",
@@ -383,6 +387,7 @@ func TestRegExp_IssueAlphanumericPattern(t *testing.T) {
383387
"ABC",
384388
"GG-",
385389
"rm-1",
390+
"[]",
386391
}
387392

388393
for _, testCase := range trueTestCases {

0 commit comments

Comments
 (0)