Skip to content

Commit 5d721d6

Browse files
committed
add empty protocol to link whitelist for IE relative links
1 parent cea9455 commit 5d721d6

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/lib/svg_text_utils.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,13 @@ var TAG_CLOSE = {
252252
sub: '<tspan dy="-0.21em">&#x200b;</tspan>'
253253
};
254254

255-
var PROTOCOLS = ['http:', 'https:', 'mailto:'];
255+
/*
256+
* Whitelist of protocols in user-supplied urls. Mostly we want to avoid javascript
257+
* and related attack vectors. The empty string is there for IE, that treats
258+
* relative paths as having no protocol, while other browsers have these explicitly
259+
* inherit the protocol of the page they're in.
260+
*/
261+
var PROTOCOLS = ['http:', 'https:', 'mailto:', ''];
256262

257263
var STRIP_TAGS = new RegExp('</?(' + Object.keys(TAG_STYLES).join('|') + ')( [^>]*)?/?>', 'g');
258264

0 commit comments

Comments
 (0)