File tree Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Expand file tree Collapse file tree 1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -184,6 +184,14 @@ export function segment(
184
184
: [ ...graphemeSegmenter . segment ( content ) ] . map ( ( seg ) => seg . segment )
185
185
}
186
186
187
+ function encodeAttributeValue ( value : string ) {
188
+ return value
189
+ . replace ( / " / g, '"' )
190
+ . replace ( / < / g, '<' )
191
+ . replace ( / > / g, '>' )
192
+ . replace ( / & / g, '&' )
193
+ }
194
+
187
195
export function buildXMLString (
188
196
type : string ,
189
197
attrs : Record < string , any > ,
@@ -193,7 +201,11 @@ export function buildXMLString(
193
201
194
202
for ( const [ k , _v ] of Object . entries ( attrs ) ) {
195
203
if ( typeof _v !== 'undefined' ) {
196
- attrString += ` ${ k } ="${ _v } "`
204
+ if ( typeof _v === 'string' ) {
205
+ attrString += ` ${ k } ="${ encodeAttributeValue ( _v ) } "`
206
+ } else {
207
+ attrString += ` ${ k } ="${ _v } "`
208
+ }
197
209
}
198
210
}
199
211
You can’t perform that action at this time.
0 commit comments