Relax attribute escaping. Fixes #26
This commit is contained in:
parent
9c81041cac
commit
1588f30353
|
@ -337,7 +337,7 @@ impl Declare {
|
|||
for (attr_name, _, attr_str) in self.attrs() {
|
||||
print_attrs.extend(quote!(
|
||||
if let Some(ref value) = self.attrs.#attr_name {
|
||||
let value = ::htmlescape::encode_attribute(&value.to_string());
|
||||
let value = crate::escape_html_attribute(value.to_string());
|
||||
if !value.is_empty() {
|
||||
write!(f, " {}=\"{}\"", #attr_str, value)?;
|
||||
}
|
||||
|
@ -355,7 +355,7 @@ impl Declare {
|
|||
#print_attrs
|
||||
for (key, value) in &self.data_attributes {
|
||||
write!(f, " data-{}=\"{}\"", key,
|
||||
::htmlescape::encode_attribute(&value))?;
|
||||
crate::escape_html_attribute(value.to_string()))?;
|
||||
}
|
||||
write!(f, "{}", self.events)?;
|
||||
#print_children
|
||||
|
|
|
@ -227,3 +227,11 @@ impl OutputType for String {
|
|||
type EventTarget = ();
|
||||
type EventListenerHandle = ();
|
||||
}
|
||||
|
||||
pub fn escape_html_attribute(html_attr: String) -> String {
|
||||
// Even though the code is quoting the variables with a double quote, escape all known quoting chars
|
||||
html_attr
|
||||
.replace("\"", """)
|
||||
.replace("'", "'")
|
||||
.replace("`", "`")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue