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

Commit 8ee8ffe

Browse files
lgalfasopetebacondarwin
authored andcommitted
fix(linky): encode double quotes when serializing email addresses
Email addresses can (under certain restrictions) include double quote characters. See http://tools.ietf.org/html/rfc3696#section-3. For example, `"Jo Bloggs"@abc.com` is a valid email address. When serializing emails to the `href` attribute of an anchor element, we must HTML encode these double quote characters. See http://www.w3.org/TR/html-markup/syntax.html#syntax-attr-double-quoted This commit does not attempt to improve the functionality (i.e. regex) that attempts to identify email addresses in a general string. Closes #8945 Closes #8964 Closes #5946 Closes #10090 Closes #9256
1 parent 42d09f1 commit 8ee8ffe

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/ngSanitize/filter/linky.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ angular.module('ngSanitize').filter('linky', ['$sanitize', function($sanitize) {
142142
'" ');
143143
}
144144
html.push('href="',
145-
url,
145+
url.replace('"', '"'),
146146
'">');
147147
addText(text);
148148
html.push('</a>');

test/ngSanitize/filter/linkySpec.js

+4
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ describe('linky', function() {
2929
toEqual('my email is &#34;<a href="mailto:me@example.com">me@example.com</a>&#34;');
3030
});
3131

32+
it('should handle quotes in the email', function() {
33+
expect(linky('foo@"bar.com')).toEqual('<a href="mailto:foo@&#34;bar.com">foo@&#34;bar.com</a>');
34+
});
35+
3236
it('should handle target:', function() {
3337
expect(linky("http://example.com", "_blank")).
3438
toEqual('<a target="_blank" href="http://example.com">http://example.com</a>');

0 commit comments

Comments
 (0)