From 7c6be43e83590798cffef63d076fb79d5296fba2 Mon Sep 17 00:00:00 2001 From: Mike Stickel Date: Sun, 12 Oct 2014 12:11:19 -0700 Subject: [PATCH] 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 --- src/ngSanitize/filter/linky.js | 2 +- test/ngSanitize/filter/linkySpec.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/ngSanitize/filter/linky.js b/src/ngSanitize/filter/linky.js index 7a653893..3f76d994 100644 --- a/src/ngSanitize/filter/linky.js +++ b/src/ngSanitize/filter/linky.js @@ -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) { diff --git a/test/ngSanitize/filter/linkySpec.js b/test/ngSanitize/filter/linkySpec.js index fc442e4c..48c7c1f7 100644 --- a/test/ngSanitize/filter/linkySpec.js +++ b/test/ngSanitize/filter/linkySpec.js @@ -10,11 +10,13 @@ describe('linky', function() { })); it('should do basic filter', function() { - expect(linky("http://ab/ (http://a/) http://1.2/v:~-123. c")). + expect(linky("http://ab/ (http://a/) http://1.2/v:~-123. c “http://example.com” ‘http://me.com’")). toEqual('http://ab/ ' + '(http://a/) ' + '<http://a/> ' + - 'http://1.2/v:~-123. c'); + 'http://1.2/v:~-123. c ' + + '“http://example.com” ' + + '‘http://me.com’'); expect(linky(undefined)).not.toBeDefined(); });