vmg / rinku

Autolinking. Ruby. Yes, that's pretty much it.
ISC License
597 stars 67 forks source link

Trailing non-breaking space included in link #73

Open dukebrown opened 6 years ago

dukebrown commented 6 years ago

If an input string contains a non-breaking space ( ) immediately after a URL, the non-breaking space and the next word are included in the link.

For example, this string works: http://example.com test. (It becomes <a href="http://example.com/">http://example.com/</a> test.)

However, this string does not work: http://example.com/&nbsp;test. (It becomes <a href="http://example.com/&nbsp;test\">http://example.com/&nbsp;test</a>.)

This also affects strings containing a closing bracket (parenthesis, square bracket, or curly bracket) between the URL and the non-breaking space. For example: website (http://example.com/)&nbsp;of the user becomes website (<a href="http://example.com/)&nbsp;of\">http://example.com/)&nbsp;of</a> the user.

kivikakk commented 6 years ago

I can confirm this; we check to see if an entity is at the end of an autolinked URL and remove it accordingly, but if one appears 'within' a candidate we don't detect or notice it. I'm not sure this edge case is enough for us to redo how the delimiter detection works, i.e. to scan within a URL for an entity. We don't and likely will not ever do full entity detection; you might consider using an actual markup language (like Markdown) if you need to be this precise — or insert the non-breaking space directly into the source material, as rinku will work around that. (Worth also keeping in mind that &…; may appear within a real URL.)