From adf07543af23abadf7fdf926d7ba1f358151682a Mon Sep 17 00:00:00 2001 From: Mike Stickel Date: Sun, 12 Oct 2014 12:11:19 -0700 Subject: [PATCH] fix(ngSanitize): update to exclude smart quotes Request Type: bug How to reproduce: Add a smart quote (single or double) at the end of a url string and filter the string with linky. Example plunker: http://plnkr.co/edit/CeB5x48U0D1eXq4yXkvk?p=preview Component(s): ngSanitize Impact: small Complexity: small Detailed Description: When smart quotes are included in content filtered through linky, any smart quote at the end of a URL string will be included in the link text and the href. --- 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 efaa54d8b3c3..99001e527863 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 a09d78688fd8..2e1e23d30423 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(); });