fix(ngSanitize): exclude smart quotes at the end of the link

When smart quotes are included in content filtered through linky, any
smart quote at the end of a URL string was being included in the link
text and the href.

Closes #7307
This commit is contained in:
Mike Stickel
2014-10-12 12:11:19 -07:00
committed by Peter Bacon Darwin
parent e93710fe0e
commit 7c6be43e83
2 changed files with 5 additions and 3 deletions

View File

@@ -104,7 +104,7 @@
*/
angular.module('ngSanitize').filter('linky', ['$sanitize', function($sanitize) {
var LINKY_URL_REGEXP =
/((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"]/,
/((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"”’]/,
MAILTO_REGEXP = /^mailto:/;
return function(text, target) {

View File

@@ -10,11 +10,13 @@ describe('linky', function() {
}));
it('should do basic filter', function() {
expect(linky("http://ab/ (http://a/) <http://a/> http://1.2/v:~-123. c")).
expect(linky("http://ab/ (http://a/) <http://a/> http://1.2/v:~-123. c “http://example.com” http://me.com")).
toEqual('<a href="http://ab/">http://ab/</a> ' +
'(<a href="http://a/">http://a/</a>) ' +
'&lt;<a href="http://a/">http://a/</a>&gt; ' +
'<a href="http://1.2/v:~-123">http://1.2/v:~-123</a>. c');
'<a href="http://1.2/v:~-123">http://1.2/v:~-123</a>. c ' +
'&#8220;<a href="http://example.com">http://example.com</a>&#8221; ' +
'&#8216;<a href="http://me.com">http://me.com</a>&#8217;');
expect(linky(undefined)).not.toBeDefined();
});