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

URL links with double quotes are not parsed/rendered correctly #327

Open
aleybovich opened this issue Dec 4, 2024 · 3 comments
Open

URL links with double quotes are not parsed/rendered correctly #327

aleybovich opened this issue Dec 4, 2024 · 3 comments

Comments

@aleybovich
Copy link

aleybovich commented Dec 4, 2024

Example:

[Some site](https://somesite.com/?"something%20in%20quotes"(blah)harp)

Renders as:

Somesiteharp)

Where Somesite renders as a link and harp) as text

If I replace double quotes with %22, then it renders correctly as Somesite link. In other words, this renders as expected:

[Some site](https://somesite.com/?%22something%20in%20quotes%22(blah)harp)

Renders as link:

Somesite

Other markdown libraries (including VS Code markdown preview) render urls with quotes correctly.

@kjk
Copy link
Contributor

kjk commented Dec 4, 2024

Provide a minimal repro i.e. remove 99% of unnecessary stuff from the URL.

Provide https://babelmark.github.io/ link (press CONVERT button to get shareable link).

Provide equivalent test case by modifying https://arslexis.io/goplayground/#txO7hJ-ibeU and use Share button to get link to your use cases.

@aleybovich
Copy link
Author

aleybovich commented Dec 5, 2024

@kjk I updated the description with a simple example

Babelmark link: https://babelmark.github.io/?text=%5BSome+site%5D(https%3A%2F%2Fsomesite.com%2F%3F%22something%2520in%2520quotes%22(blah)harp)

You can see that most markdown libraries render it correctly and only a few like markuru, mini-markddown and markus render it with an issue, like what I reported above

Test case: https://arslexis.io/goplayground/#cpdqcJHQ0qV

You can see that it outputs

<p><a href="https://somesite.com/?&quot;something%20in%20quotes&quot;(blah" target="_blank">Some site</a>harp)</p>

which is incorrect, as it should be

<p><a href="https://somesite.com/?&quot;something%20in%20quotes&quot;(blah)harp" target="_blank">Some site</a></p>

@kjk
Copy link
Contributor

kjk commented Dec 5, 2024

Even shorter:

Test case:

[site](https://a.com/s"())

Two problems:

  • "foo" should be parsed as title="foo" attribute but only if it's at the end and after a space i.e. (https://a.com/foo "title")
  • we encode " as &quot; but other implementations do %22 or "

Having " or ' in URL breaks the logic for balanced () check.

We should require a space before title start ('") and that after (`'") title end we only have space or ')'.

Not exactly a simple fix. The change would be in link() in inline.go.

kjk added a commit that referenced this issue Dec 5, 2024
and simplify link parsing a bit
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