@@ -78,24 +78,12 @@ module.exports = function toSVG(gd, format) {
78
78
return ;
79
79
}
80
80
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)
96
84
var ff = txt . style ( 'font-family' ) ;
97
85
if ( ff && ff . indexOf ( '"' ) !== - 1 ) {
98
- txt . style ( 'font-family' , ff . replace ( / " / g, '\\\' ' ) ) ;
86
+ txt . style ( 'font-family' , ff . replace ( / " / g, 'TOBESTRIPPED ' ) ) ;
99
87
}
100
88
} ) ;
101
89
@@ -115,5 +103,8 @@ module.exports = function toSVG(gd, format) {
115
103
s = svgTextUtils . html_entity_decode ( s ) ;
116
104
s = svgTextUtils . xml_entity_encode ( s ) ;
117
105
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
+
118
109
return s ;
119
110
} ;
0 commit comments