-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove visitLinksForShortLinks features #6257
Remove visitLinksForShortLinks features #6257
Conversation
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 (go-gitea#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.
Codecov Report
@@ Coverage Diff @@
## master #6257 +/- ##
========================================
Coverage ? 38.8%
========================================
Files ? 355
Lines ? 50253
Branches ? 0
========================================
Hits ? 19502
Misses ? 27922
Partials ? 2829
Continue to review full report at Codecov.
|
I too am confused as to why this was originally there. Does this change break bold styling of the links etc? |
It shouldn't since it only deals with the shortLinkProcessorFull function which doesn't handle any styling that I can see and returns a link when successful in any case. So all this change does is not run the following function: Line 379 in ad86b84
... on the text inside of an existing link. |
This should probably get a kind/bug tag as well -- when I was working on another branch without this fix I copied some test URLS which happened to included the example case from #4946 and it causes a 500 and none of the text to render at all |
@mrsdizzie thanks again for all the PRs you are sending. It is appreciated, and adding tests is especially appreciated. |
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 becaused you can't have nested links within an existing <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 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 as this would try. In practice none of this should work anyway 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 that I can see.
This removes the feature and also explicitly excludes the current visitNodeForShortLinks from looking in <a> tags.
Open to feedback if anybody knows of a legitimate use for this, but it appears to have been added as part of a much larger commit ( 535445c) without specific explanation as to the use case behind this. Thanks!