summaryrefslogtreecommitdiffstats
path: root/modules/markup/html_test.go
diff options
context:
space:
mode:
authormrsdizzie <joe.mccann@gmail.com>2019-03-07 14:13:44 -0500
committertechknowlogick <matti@mdranta.net>2019-03-07 14:13:44 -0500
commit020075e12fe4f3bc4fb632909309da97ed537c34 (patch)
tree3102bbd2b6b8106e40ab2e69400edce0d7b8833d /modules/markup/html_test.go
parentad86b843e1d1984ec1b69f51276654469644bdd5 (diff)
downloadgitea-020075e12fe4f3bc4fb632909309da97ed537c34.tar.gz
gitea-020075e12fe4f3bc4fb632909309da97ed537c34.zip
Remove visitLinksForShortLinks features (#6257)
The visitLinksForShortLinks feature would look inside of an <a> tag and run shortLinkProcessorFull on any text, which attempts to create links out of potential 'short links' like [[test]] [[link|example]] etc... This makes no sense because you can't have nested links within an <a> tag. Specifically, the html5 standard says <a> tags can't include interactive content if they contain the href attribute: http://w3c.github.io/html/single-page.html#the-a-element And also defines an <a> element with a href attribute as interactive: http://w3c.github.io/html/single-page.html#interactive-content Therefore you can't really put a link inside of another link. In practice none of this works anyways since browsers won't render it, it would probably be broken if they tried, and it is causing a bug (#4946). No current tests rely on this behavior either. This removes the feature and also explicitly excludes the current visitNodeForShortLinks from looking in <a> tags.
Diffstat (limited to 'modules/markup/html_test.go')
-rw-r--r--modules/markup/html_test.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/modules/markup/html_test.go b/modules/markup/html_test.go
index f17d00cd67..f430cb04be 100644
--- a/modules/markup/html_test.go
+++ b/modules/markup/html_test.go
@@ -222,4 +222,8 @@ func TestRender_ShortLinks(t *testing.T) {
"[[some/path/Link #.jpg]]",
`<p><a href="`+notencodedImgurl+`" rel="nofollow"><img src="`+notencodedImgurl+`"/></a></p>`,
`<p><a href="`+notencodedImgurlWiki+`" rel="nofollow"><img src="`+notencodedImgurlWiki+`"/></a></p>`)
+ test(
+ "<p><a href=\"https://example.org\">[[foobar]]</a></p>",
+ `<p><a href="https://example.org" rel="nofollow">[[foobar]]</a></p>`,
+ `<p><a href="https://example.org" rel="nofollow">[[foobar]]</a></p>`)
}