File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -337,7 +337,7 @@ impl Declare {
337
337
for ( attr_name, _, attr_str) in self . attrs ( ) {
338
338
print_attrs. extend ( quote ! (
339
339
if let Some ( ref value) = self . attrs. #attr_name {
340
- let value = :: htmlescape :: encode_attribute ( & value. to_string( ) ) ;
340
+ let value = crate :: escape_html_attribute ( value. to_string( ) ) ;
341
341
if !value. is_empty( ) {
342
342
write!( f, " {}=\" {}\" " , #attr_str, value) ?;
343
343
}
@@ -355,7 +355,7 @@ impl Declare {
355
355
#print_attrs
356
356
for ( key, value) in & self . data_attributes {
357
357
write!( f, " data-{}=\" {}\" " , key,
358
- :: htmlescape :: encode_attribute ( & value) ) ?;
358
+ crate :: escape_html_attribute ( value. to_string ( ) ) ) ?;
359
359
}
360
360
write!( f, "{}" , self . events) ?;
361
361
#print_children
Original file line number Diff line number Diff line change @@ -227,3 +227,11 @@ impl OutputType for String {
227
227
type EventTarget = ( ) ;
228
228
type EventListenerHandle = ( ) ;
229
229
}
230
+
231
+ pub fn escape_html_attribute ( html_attr : String ) -> String {
232
+ // Even though the code is quoting the variables with a double quote, escape all known quoting chars
233
+ html_attr
234
+ . replace ( "\" " , """ )
235
+ . replace ( "'" , "'" )
236
+ . replace ( "`" , "`" )
237
+ }
You can’t perform that action at this time.
0 commit comments