@@ -125,24 +125,12 @@ module.exports = function toSVG(gd, format) {
125
125
return ;
126
126
}
127
127
128
- // I've seen font-family styles with non-escaped double quotes in them - breaks the
129
- // serialized svg because the style attribute itself is double-quoted!
130
- // Is this an IE thing? Any other attributes or style elements that can have quotes in them?
131
- // TODO: this looks like a noop right now - what happened to it?
132
-
133
- /*
134
- * Font-family styles with double quotes in them breaks the to-image
135
- * step in FF42 because the style attribute itself is wrapped in
136
- * double quotes. See:
137
- *
138
- * - http://codepen.io/etpinard/pen/bEdQWK
139
- * - https://github.com/plotly/plotly.js/pull/104
140
- *
141
- * for more info.
142
- */
128
+ // Font family styles break things because of quotation marks,
129
+ // so we must remove them *after* the SVG DOM has been serialized
130
+ // to a string (browsers convert singles back)
143
131
var ff = txt . style ( 'font-family' ) ;
144
132
if ( ff && ff . indexOf ( '"' ) !== - 1 ) {
145
- txt . style ( 'font-family' , ff . replace ( / " / g, '\\\' ' ) ) ;
133
+ txt . style ( 'font-family' , ff . replace ( / " / g, 'TOBESTRIPPED ' ) ) ;
146
134
}
147
135
} ) ;
148
136
@@ -162,6 +150,9 @@ module.exports = function toSVG(gd, format) {
162
150
s = svgTextUtils . html_entity_decode ( s ) ;
163
151
s = svgTextUtils . xml_entity_encode ( s ) ;
164
152
153
+ // Fix quotations around font strings
154
+ 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, '\'' ) ;
155
+
165
156
return s ;
166
157
} ;
167
158
0 commit comments