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

Commit adf0754

Browse files
Mike Stickelstickel
Mike Stickel
authored andcommitted
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.
1 parent 353de4f commit adf0754

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/ngSanitize/filter/linky.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@
104104
*/
105105
angular.module('ngSanitize').filter('linky', ['$sanitize', function($sanitize) {
106106
var LINKY_URL_REGEXP =
107-
/((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"]/,
107+
/((ftp|https?):\/\/|(mailto:)?[A-Za-z0-9._%+-]+@)\S*[^\s.;,(){}<>"]/,
108108
MAILTO_REGEXP = /^mailto:/;
109109

110110
return function(text, target) {

test/ngSanitize/filter/linkySpec.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,13 @@ describe('linky', function() {
1010
}));
1111

1212
it('should do basic filter', function() {
13-
expect(linky("http://ab/ (http://a/) <http://a/> http://1.2/v:~-123. c")).
13+
expect(linky("http://ab/ (http://a/) <http://a/> http://1.2/v:~-123. c “http://example.com” ‘http://me.com’")).
1414
toEqual('<a href="http://ab/">http://ab/</a> ' +
1515
'(<a href="http://a/">http://a/</a>) ' +
1616
'&lt;<a href="http://a/">http://a/</a>&gt; ' +
17-
'<a href="http://1.2/v:~-123">http://1.2/v:~-123</a>. c');
17+
'<a href="http://1.2/v:~-123">http://1.2/v:~-123</a>. c ' +
18+
'&#8220;<a href="http://example.com">http://example.com</a>&#8221; ' +
19+
'&#8216;<a href="http://me.com">http://me.com</a>&#8217;');
1820
expect(linky(undefined)).not.toBeDefined();
1921
});
2022

0 commit comments

Comments
 (0)