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

Commit 929dd15

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 1b9e408 commit 929dd15

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/ngSanitize/filter/linky.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ angular.module('ngSanitize').filter('linky', ['$sanitize', function($sanitize) {
141141
html.push(target);
142142
html.push('" ');
143143
}
144-
html.push('href="');
145-
html.push(url);
146-
html.push('">');
144+
html.push('href="',
145+
url.replace('"', '"'),
146+
'">');
147147
addText(text);
148148
html.push('</a>');
149149
}

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)