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

AutoLink extension links invalid protocol-only (no host) URIs #99

Closed
peckjon opened this issue Aug 29, 2017 · 6 comments
Closed

AutoLink extension links invalid protocol-only (no host) URIs #99

peckjon opened this issue Aug 29, 2017 · 6 comments

Comments

@peckjon
Copy link

peckjon commented Aug 29, 2017

It is common to type only "http://" (not followed by any hostname etc) in the process of creating technical documentation.

The AutoLink extension incorrectly attempts to link these, resulting in ugly documentation.

URIs are invalid without a host portion:

URI = scheme ":" hier-part [ "?" query ] [ "#" fragment ]

hier-part = "//" authority path-abempty
                 / path-absolute
                 / path-rootless
                 / path-empty

authority = [ userinfo "@" ] host [ ":" port ]
@robinst
Copy link
Collaborator

robinst commented Aug 30, 2017

http:// by itself should not get autolinked. Do you type "http://" (including the quotes)? If so, that's a bug in autolink-java which I should fix.

@peckjon
Copy link
Author

peckjon commented Aug 30, 2017

Thanks for the quick response! The line I typed was:

* **(Required):** Images ("images": ["data://...", "http://...", ...])

...and on more careful inspection (sorry!), the linked portion includes [only] the first dot (eg, http://.)

Is http://. a valid URL? Technically, I'm not sure (one could perhaps argue that unreserved = ALPHA / DIGIT / "-" / "." / "_" / "~" makes it valid). Logically, no, but I suppose that's because . is an invalid TLD.

PS md in context: https://algorithmia.com/algorithms/web/SocialMediaImageRecommender

@robinst
Copy link
Collaborator

robinst commented Aug 31, 2017

Thanks for including the full source :).

Yeah, I think it's valid because host can just be a single unreserved character. Having said that, even just http:// is valid according to RFC 3986, but we don't autolink it. And for valid URLs that end with a ., we don't include . either.

I've raised robinst/autolink-java#15 to fix it there, but we can also leave this one open until we bump the dependency here.

@peckjon
Copy link
Author

peckjon commented Aug 31, 2017

Wow that was fast @robinst -- I see robinst/autolink-java#15 is already fixed!

Thanks for being awesome. Closing out.

@peckjon peckjon closed this as completed Aug 31, 2017
robinst added a commit that referenced this issue Sep 1, 2017
This change stops these and other examples from being linked:

    http://.
    http://"
    http://<space>
@robinst
Copy link
Collaborator

robinst commented Sep 19, 2017

@peckjon
Copy link
Author

peckjon commented Sep 19, 2017

Awesome, Robin! Thanks!!

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