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

Existence of greater and lower signs in links gives different behaviour. #954

Closed
jsmonkey opened this issue Nov 21, 2017 · 2 comments
Closed
Labels
help wanted L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue

Comments

@jsmonkey
Copy link

Hey guys,

I'm using markdown-link-extractor. And this module uses ur library as a dependency.

After extracting the links, I have different results on each link from amount of invalid links, which triggers the issues and unexpected results in my application.

For example:
Extracting from this piece of markdown

[link](http://www.cnn.com>)

gives me:

http://www.cnn.com>

which is right, cuz this link is invalid.

But from this one with lower sign:

[link](http://www.cnn.com<)

it extracts:

http://www.cnn.com

which is not true, cuz returned link is valid, but in markdown I still have link with wrong sign.

I think that it's some kind of error with regular expressions in existing codebase of ur module.
Anyways it would be nice to have a fix on that and mb new version of lib where everything works as expected.

Thanks.

@joshbruce joshbruce added help wanted L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue labels Dec 1, 2017
@joshbruce
Copy link
Member

#984

@Feder1co5oave
Copy link
Contributor

Feder1co5oave commented Dec 27, 2017

I think you hit something bad here.
Per commonmark specs, link destinations can be delimited by < and >, or not.
http://spec.commonmark.org/0.28/#link-destination

From running your examples, I actually obtain the opposite result:

$ bin/marked
[link](http://www.cnn.com>)
[link](http://www.cnn.com<)
^D
<p><a href="http://www.cnn.com">link</a>
<a href="http://www.cnn.com&lt;">link</a></p>

Problem is, marked should trim angle brackets at beginning or end of hrefs only if they are both present, whereas the current regex trims any of them. In the second example, it is an opening < at the end of the href, so it is kept and escaped.

I suggest marking this as broken @joshbruce
edit: awww, you've already done that :D

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted L1 - broken Valid usage causes incorrect output OR a crash AND there is no known workaround for the issue
Projects
None yet
Development

No branches or pull requests

3 participants