Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Linky filter in angular-sanitize is ignoring last parenthesis in URL ending with a parenthesis #7213

Open
jd2791 opened this issue Apr 23, 2014 · 6 comments

Comments

@jd2791
Copy link

jd2791 commented Apr 23, 2014

Using angular-santize.js 1.2.9 and angular.js 1.2.9, the linky filter ignores the final parenthesis in a given URL that has a parenthesis as the last character. This appears to happen in all browsers. An example can be found here: http://jsfiddle.net/Uqg9D/1/

@petebacondarwin
Copy link
Contributor

@petebacondarwin
Copy link
Contributor

Clearly this is not correct but to fix this is problematic.

The current regex in linky is here: https://github.com/angular/angular.js/blob/master/src/ngSanitize/filter/linky.js#L106

/((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>]/

This is not including any trailing punctuation, presumable so that URLs can be found that end sentences, and are enclosed in brackets, etc.

But URLs, according to the spec, can end with any "xalpha":

  xalpha                  alpha | digit | safe | extra | escape

where notably,

  safe                    $ | - | _ | @ | . | &  | + | -                        
  extra                  ! | * |  " |  ' | ( | )  | , 

So URLs can indeed end with full stops and parenthesis.

Allowing them will break people's expectation of how link should work in free form text but disallowing them potentially fails to match valid URLs.

Any thoughts?

@petebacondarwin
Copy link
Contributor

The markdown solution is to require "automatic" URLs to be wrapped in < angle brackets >

@petebacondarwin petebacondarwin added this to the Backlog milestone Apr 24, 2014
@jd2791
Copy link
Author

jd2791 commented Apr 25, 2014

I think the markdown solution is good. Changing the existing regex to fix a problem that isn't too big of an issue, especially since it hasn't been mentioned thus far, doesn't seem worth it to possibly miss valid URLs. Having some way to flag URLs seems like a good compromise.

@Narretz
Copy link
Contributor

Narretz commented Apr 19, 2016

Just checking on some 1.2.x labelled issues. This is still valid in 1.5.5.

@zucher
Copy link

zucher commented Feb 15, 2017

Failure still present into 1.5.7 and 1.6.1 version, tests done with:
https://fr.wikipedia.org/wiki/Hollands_Diep_(rivi%C3%A8re)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

5 participants