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

Stop URL on < or > #7

Closed
tsl0922 opened this issue May 14, 2016 · 3 comments
Closed

Stop URL on < or > #7

tsl0922 opened this issue May 14, 2016 · 3 comments

Comments

@tsl0922
Copy link

tsl0922 commented May 14, 2016

code to reproduce:

String input = "wow <p>http://test.com</p> such linked";
LinkExtractor linkExtractor = LinkExtractor.builder().build();
Iterable<LinkSpan> links = linkExtractor.extractLinks(input);
String result = Autolink.renderLinks(input, links, (link, text, sb) -> {
    sb.append("<a href=\"");
    sb.append(text, link.getBeginIndex(), link.getEndIndex());
    sb.append("\">");
    sb.append(text, link.getBeginIndex(), link.getEndIndex());
    sb.append("</a>");
});
System.out.println(result);

expect:

wow <p><a href="http://test.com">http://test.com</a></p> such linked

actual:

wow <p><a href="http://test.com</p>">http://test.com</p></a> such linked

This seems to be a bug, do we support the skip_tags feature of rinku?

@robinst
Copy link
Owner

robinst commented May 17, 2016

We don't try to parse HTML, this library is about detecting links in plain text.

Having said that, unescaped < or > is not actually valid in a URL (or IRI) according to RFC 3987 section 2.2, so we shouldn't accept it.

I'll make this issue about that.

@robinst robinst changed the title link inside html tags Stop URL on < or > May 17, 2016
robinst added a commit that referenced this issue Jun 24, 2016
Before, we would allow angle brackets if they were balanced
(http://example.org/<>). But according to RFC 3987, angle brackets are
not allowed in URLs, and other linkers don't seem to allow them either.

Also add some more control characters in ASCII range to that list.
@robinst
Copy link
Owner

robinst commented Jun 24, 2016

Fixed now, will release soon.

@robinst
Copy link
Owner

robinst commented Jun 26, 2016

Released in 0.5.0 now.

@robinst robinst closed this as completed Jun 26, 2016
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