From 84cb18aac7a3ebdb01438fc47a5f29bdbd755768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6berl?= Date: Thu, 25 Jan 2018 10:56:44 +0100 Subject: [PATCH 1/2] Allow square brackets in external issue patterns --- modules/markup/html.go | 4 ++-- modules/markup/html_test.go | 2 ++ 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/modules/markup/html.go b/modules/markup/html.go index 532533976257c..0eb6337d24887 100644 --- a/modules/markup/html.go +++ b/modules/markup/html.go @@ -38,9 +38,9 @@ var ( MentionPattern = regexp.MustCompile(`(\s|^|\W)@[0-9a-zA-Z-_\.]+`) // IssueNumericPattern matches string that references to a numeric issue, e.g. #1287 - IssueNumericPattern = regexp.MustCompile(`( |^|\()#[0-9]+\b`) + IssueNumericPattern = regexp.MustCompile(`( |^|\(|\[)#[0-9]+\b`) // IssueAlphanumericPattern matches string that references to an alphanumeric issue, e.g. ABC-1234 - IssueAlphanumericPattern = regexp.MustCompile(`( |^|\()[A-Z]{1,10}-[1-9][0-9]*\b`) + IssueAlphanumericPattern = regexp.MustCompile(`( |^|\(|\[)[A-Z]{1,10}-[1-9][0-9]*\b`) // CrossReferenceIssueNumericPattern matches string that references a numeric issue in a different repository // e.g. gogits/gogs#12345 CrossReferenceIssueNumericPattern = regexp.MustCompile(`( |^)[0-9a-zA-Z]+/[0-9a-zA-Z]+#[0-9]+\b`) diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index e3597a4c3a1b0..a91f4f6acf55f 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -342,6 +342,7 @@ func TestRegExp_IssueNumericPattern(t *testing.T) { "#1234", "#0", "#1234567890987654321", + "[#1234]", } falseTestCases := []string{ "# 1234", @@ -368,6 +369,7 @@ func TestRegExp_IssueAlphanumericPattern(t *testing.T) { "A-1", "RC-80", "ABCDEFGHIJ-1234567890987654321234567890", + "[JIRA-134]", } falseTestCases := []string{ "RC-08", From bcc1a6dddad2ac482d2318c0e8a6d12a48fbf063 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6berl?= Date: Sat, 27 Jan 2018 07:28:33 +0100 Subject: [PATCH 2/2] Added false test cases for checklist elements --- modules/markup/html_test.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go index a91f4f6acf55f..98fcc394ea8bd 100644 --- a/modules/markup/html_test.go +++ b/modules/markup/html_test.go @@ -353,6 +353,8 @@ func TestRegExp_IssueNumericPattern(t *testing.T) { "#1A2B", "", "ABC", + "[]", + "[x]", } for _, testCase := range trueTestCases { @@ -382,6 +384,7 @@ func TestRegExp_IssueAlphanumericPattern(t *testing.T) { "ABC", "GG-", "rm-1", + "[]", } for _, testCase := range trueTestCases {