@@ -78,24 +78,12 @@ module.exports = function toSVG(gd, format) {
7878 return ;
7979 }
8080
81- // I've seen font-family styles with non-escaped double quotes in them - breaks the
82- // serialized svg because the style attribute itself is double-quoted!
83- // Is this an IE thing? Any other attributes or style elements that can have quotes in them?
84- // TODO: this looks like a noop right now - what happened to it?
85-
86- /*
87- * Font-family styles with double quotes in them breaks the to-image
88- * step in FF42 because the style attribute itself is wrapped in
89- * double quotes. See:
90- *
91- * - http://codepen.io/etpinard/pen/bEdQWK
92- * - https://github.com/plotly/plotly.js/pull/104
93- *
94- * for more info.
95- */
81+ // Font family styles break things because of quotation marks,
82+ // so we must remove them *after* the SVG DOM has been serialized
83+ // to a string (browsers convert singles back)
9684 var ff = txt . style ( 'font-family' ) ;
9785 if ( ff && ff . indexOf ( '"' ) !== - 1 ) {
98- txt . style ( 'font-family' , ff . replace ( / " / g, '\\\' ' ) ) ;
86+ txt . style ( 'font-family' , ff . replace ( / " / g, 'TOBESTRIPPED ' ) ) ;
9987 }
10088 } ) ;
10189
@@ -115,5 +103,8 @@ module.exports = function toSVG(gd, format) {
115103 s = svgTextUtils . html_entity_decode ( s ) ;
116104 s = svgTextUtils . xml_entity_encode ( s ) ;
117105
106+ // Fix quotations around font strings
107+ s = s . replace ( / ( " T O B E S T R I P P E D ) | ( T O B E S T R I P P E D " ) / g, '\'' ) ;
108+
118109 return s ;
119110} ;
0 commit comments