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

Commit 7c6be43

Browse files
Mike Stickelpetebacondarwin
Mike Stickel
authored andcommitted
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
1 parent e93710f commit 7c6be43

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/ngSanitize/filter/linky.js

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 2 deletions
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)