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

& in a url query gets escaped and re-written to & #1525

Closed
zeusdeux opened this issue Jul 15, 2019 · 2 comments
Closed

& in a url query gets escaped and re-written to & #1525

zeusdeux opened this issue Jul 15, 2019 · 2 comments

Comments

@zeusdeux
Copy link

Describe the bug
& in the query section of a URI gets escaped and re-written to & thus breaking the link.

To be very honest, I am not quite sure this is a bug since commonmark.js dingus produces the same result. But, for e.g., GitHub doesn't escape &.

More of a question around why and how to handle the change in semantics introduced by the escaping of &.

To Reproduce
Steps to reproduce the behavior: (both produce the same output so this is more for ease of discovery)

  1. Marked Demo
  2. CommonMark Demo

Expected behavior
& in query section of an URI should not be escaped as it changes the semantics of the query params.

@UziTech
Copy link
Member

UziTech commented Jul 15, 2019

GitHub doesn't escape &.

I'm not sure that is the case. Even though the html output from marked and commonmark has & the browser seems to know to translate that as & and not %26 (percent encoding for &) so the links in the preview pane of both demos goes to the correct url.

The only way to see GitHub's output html is to inspect the element in dev tools, but If you inspect the links in the demos you will see that the browser has converted the & in the link to &.

So I'm guessing GitHub follows the common mark spec and the encodes it as & as well, it is just getting shown in the dev tools as &.

@zeusdeux
Copy link
Author

Yeah it's what I could see in devtools that threw me off; especially when combined with the browser still treating the links correctly. This is more of a TIL. Thanks @UziTech! Closing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants