summaryrefslogtreecommitdiffstats
path: root/modules/markup/html_internal_test.go
diff options
context:
space:
mode:
authorsilverwind <me@silverwind.io>2019-04-06 20:28:45 +0200
committerLauris BH <lauris@nix.lv>2019-04-06 21:28:45 +0300
commit2242a9f82e26ac8a4725a8ffc0aa0cfb25aed30a (patch)
treeadec26445d4dc4424bf9bade53d5e5429330e2fa /modules/markup/html_internal_test.go
parent0bdd81df9d6f13752b93dbcce19a4f703ad43fc2 (diff)
downloadgitea-2242a9f82e26ac8a4725a8ffc0aa0cfb25aed30a.tar.gz
gitea-2242a9f82e26ac8a4725a8ffc0aa0cfb25aed30a.zip
Improve SHA1 link detection (#6526)
This improves the SHA1 link detection to not pick up extraneous non-whitespace characters at the end of the URL. The '.' is a special case handled in code itself because of missing regexp lookahead support. Regex test cases: https://regex101.com/r/xUMlqh/3
Diffstat (limited to 'modules/markup/html_internal_test.go')
-rw-r--r--modules/markup/html_internal_test.go10
1 files changed, 5 insertions, 5 deletions
diff --git a/modules/markup/html_internal_test.go b/modules/markup/html_internal_test.go
index ff07bab913..b8612eb2bb 100644
--- a/modules/markup/html_internal_test.go
+++ b/modules/markup/html_internal_test.go
@@ -273,12 +273,12 @@ func TestRegExp_anySHA1Pattern(t *testing.T) {
testCases := map[string][]string{
"https://github.com/jquery/jquery/blob/a644101ed04d0beacea864ce805e0c4f86ba1cd1/test/unit/event.js#L2703": {
"a644101ed04d0beacea864ce805e0c4f86ba1cd1",
- "test/unit/event.js",
- "L2703",
+ "/test/unit/event.js",
+ "#L2703",
},
"https://github.com/jquery/jquery/blob/a644101ed04d0beacea864ce805e0c4f86ba1cd1/test/unit/event.js": {
"a644101ed04d0beacea864ce805e0c4f86ba1cd1",
- "test/unit/event.js",
+ "/test/unit/event.js",
"",
},
"https://github.com/jquery/jquery/commit/0705be475092aede1eddae01319ec931fb9c65fc": {
@@ -288,13 +288,13 @@ func TestRegExp_anySHA1Pattern(t *testing.T) {
},
"https://github.com/jquery/jquery/tree/0705be475092aede1eddae01319ec931fb9c65fc/src": {
"0705be475092aede1eddae01319ec931fb9c65fc",
- "src",
+ "/src",
"",
},
"https://try.gogs.io/gogs/gogs/commit/d8a994ef243349f321568f9e36d5c3f444b99cae#diff-2": {
"d8a994ef243349f321568f9e36d5c3f444b99cae",
"",
- "diff-2",
+ "#diff-2",
},
}