tenderlove / rails_autolink

The auto_link function from Rails
MIT License
588 stars 91 forks source link

Don’t include trailing > in auto linked URL #81

Closed ramhoj closed 1 year ago

ramhoj commented 1 year ago

This PR resolves an issue where a trailing > would be included in the URL.

Before &lt;http://example.com&gt; → <http://example.com>

After &lt;http://example.com&gt; → <http://example.com>

An example of <> being used to wrap URLs is when Gmail includes an auto-generated text part of a forwarded email by stripping the HTML and wrapping link URLs in <>.

The existing behaviour happens because we identify a URL by looking for a scheme and assume the URL continues until we encounter a small include list of characters (e.g white spaces and quotes).&gt; was not included there (and we can't use & as a stop character as it's allowed in URLs).