Closed GoogleCodeExporter closed 8 years ago
Proposed fixes:
@@ -1570,14 +1570,16 @@
// bottleneck; see Issue 218
// for details: http://code.google.com/p/svgweb/issues/detail?id=218
if (svg.indexOf(':svg ') == -1) { // was regular expression
- if (/xmlns\=['"]http:\/\/www\.w3\.org\/2000\/svg['"]/.test(svg) ==
false) {
- svg = svg.replace('<svg', '<svg xmlns="http://www.w3.org/2000/svg"');
+ if
(/xmlns(:[\w]+)?\=['"]http:\/\/www\.w3\.org\/2000\/svg['"]/.test(svg) ==
false) {
+ svg = svg.replace(/<svg([\s\/])/, '<svg
xmlns="http://www.w3.org/2000/svg"$1');
+ svg = svg.replace(/<([\w]+):svg([\s\/])/, '<$1:svg
xmlns:$1="http://www.w3.org/2000/svg"$2');
}
}
// add xlink namespace if it is not present
if (/xmlns:[^=]+=['"]http:\/\/www\.w3\.org\/1999\/xlink['"]/.test(svg) == false) {
- svg = svg.replace('<svg', '<svg
xmlns:xlink="http://www.w3.org/1999/xlink"');
+ svg = svg.replace(/<svg([\s\/])/, '<svg
xmlns:xlink="http://www.w3.org/1999/xlink"$1');
+ svg = svg.replace(/<([\w]+):svg([\s\/])/, '<$1:svg
xmlns:xlink="http://www.w3.org/1999/xlink"$2');
}
}
@@ -1638,14 +1640,14 @@
// incorrectly think these are SVG root elements. To do this, temporarily
// rename the SVG root element, then rename nested <svg> root elements
// to a temporary token that we will restore at the end of this method
- svg = svg.replace(/<(svg:)?svg/, '<$1SVGROOT'); // root <svg> element
- svg = svg.replace(/<(svg:)?svg/g, '<$1NESTEDSVG'); // nested <svg>
- svg = svg.replace(/<(svg:)?SVGROOT/, '<$1svg');
+ svg = svg.replace(/<([\w]+:)?svg([\s\/])/, '<$1SVGROOT$2'); // root
<svg> element
+ svg = svg.replace(/<([\w]+:)?svg([\s\/])/g, '<$1NESTEDSVG$2'); // nested
<svg>
+ svg = svg.replace(/<([\w]+:)?SVGROOT([\s\/])/, '<$1svg$2');
// break SVG string into pieces so that we don't incorrectly add our
// <__text> fake text nodes outside the SVG root tag
- var separator = svg.match(/<[a-zA-Z_-]*:?svg/)[0];
- var pieces = svg.split(/<[a-zA-Z_-]*:?svg/);
+ var separator = svg.match(/<[a-zA-Z_-]*:?svg[\s\/]/)[0];
+ var pieces = svg.split(/<[a-zA-Z_-]*:?svg[\s\/]/);
// extract CDATA sections temporarily so that we don't end up
// adding double <__text> blocks
@@ -1697,7 +1699,7 @@
// earlier we turned nested <svg> elements into a temporary token; restore
// them
- svg = svg.replace(/<(svg:)?NESTEDSVG/g, '<$1svg');
+ svg = svg.replace(/<([\w]+:)?NESTEDSVG/g, '<$1svg');
if (this.renderer == FlashHandler) {
// handle Flash encoding issues
-Alain
Original comment by alain.co...@gmail.com
on 18 Feb 2010 at 10:51
Original comment by bradneub...@gmail.com
on 18 Feb 2010 at 6:21
We've dropped support for custom prefixing in Issue 332. Thanks for the patch
though!
Original comment by bradneub...@gmail.com
on 8 Apr 2010 at 3:50
Original issue reported on code.google.com by
alain.co...@gmail.com
on 17 Feb 2010 at 4:51