Skip to content

Commit 119ac91

Browse files
committed
Fix RE used to correct quotes used in URLs for IE.
The `svgToImg()` function tries to normalize the SVG for compatibility with IE. However, currently it use a regular expression that is too greedy when matching the attribute values that need quotes changed from single to double. The result is that invalid XML is generated and will cause IE11 to fail with a `XML 5607` error and `svgToImg()` will never return. Edge will not complain but will receive invalid XML, which causes problems when used. This change restricts matching to only data surrounded by single quotes. Seems like a jasmine test should be added for `svgToImg()` along the lines of `it('Returns valid XML',...)`
1 parent a0f8333 commit 119ac91

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/snapshot/svgtoimg.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function svgToImg(opts) {
3535
// url in svg are single quoted
3636
// since we changed double to single
3737
// we'll need to change these to double-quoted
38-
svg = svg.replace(/(\('#)(.*)('\))/gi, '(\"$2\")');
38+
svg = svg.replace(/(\('#)([^']*)('\))/gi, '(\"$2\")');
3939
// font names with spaces will be escaped single-quoted
4040
// we'll need to change these to double-quoted
4141
svg = svg.replace(/(\\')/gi, '\"');

0 commit comments

Comments
 (0)