Skip to content
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

Merged

Conversation

mrsdizzie
Copy link
Member

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!

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-io
Copy link

Codecov Report

❗ No coverage uploaded for pull request base (master@ad86b84). Click here to learn what that means.
The diff coverage is 80%.

Impacted file tree graph

@@           Coverage Diff            @@
##             master   #6257   +/-   ##
========================================
  Coverage          ?   38.8%           
========================================
  Files             ?     355           
  Lines             ?   50253           
  Branches          ?       0           
========================================
  Hits              ?   19502           
  Misses            ?   27922           
  Partials          ?    2829
Impacted Files Coverage Δ
modules/markup/html.go 88.09% <80%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ad86b84...00a11d9. Read the comment docs.

@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Mar 6, 2019
@zeripath
Copy link
Contributor

zeripath commented Mar 7, 2019

I too am confused as to why this was originally there. Does this change break bold styling of the links etc?

@mrsdizzie
Copy link
Member Author

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:

func shortLinkProcessorFull(ctx *postProcessCtx, node *html.Node, noLink bool) {

... on the text inside of an existing link.

@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Mar 7, 2019
@mrsdizzie
Copy link
Member Author

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

@techknowlogick techknowlogick added this to the 1.8.0 milestone Mar 7, 2019
@techknowlogick
Copy link
Member

@mrsdizzie thanks again for all the PRs you are sending. It is appreciated, and adding tests is especially appreciated.

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Mar 7, 2019
@techknowlogick techknowlogick merged commit 020075e into go-gitea:master Mar 7, 2019
@go-gitea go-gitea locked and limited conversation to collaborators Nov 24, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/bug
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants