summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFederico Mena Quintero <federico@gnome.org>2022-10-24 15:26:54 -0500
committerFederico Mena Quintero <federico@gnome.org>2022-11-04 09:33:33 -0600
commit8b4642b1049df6154e37a997f14c9087ea826c17 (patch)
tree9aa2fc8c36c8239e53a16e4e2526581da6c0724d
parent8ce2723b559362b34ad09d1dc718bfe9b35e77ee (diff)
downloadlibrsvg-8b4642b1049df6154e37a997f14c9087ea826c17.tar.gz
Make parsing xml:lang and xml:space infallible
I.e. make them just log an error if parsing fails. This is a bit gross; we can refactor it later. Part-of: <https://gitlab.gnome.org/GNOME/librsvg/-/merge_requests/763>
-rw-r--r--src/properties.rs30
1 files changed, 24 insertions, 6 deletions
diff --git a/src/properties.rs b/src/properties.rs
index de642dc4..603360aa 100644
--- a/src/properties.rs
+++ b/src/properties.rs
@@ -912,18 +912,36 @@ impl SpecifiedValues {
// xml:lang is a non-presentation attribute and as such cannot have the
// "inherit" value. So, we don't call parse_one_presentation_attribute()
// for it, but rather call its parser directly.
- self.set_parsed_property(&ParsedProperty::XmlLang(SpecifiedValue::Specified(
- attr.parse(value)?,
- )));
+ let parse_result: Result<XmlLang, _> = attr.parse(value);
+ match parse_result {
+ Ok(lang) => {
+ self.set_parsed_property(&ParsedProperty::XmlLang(
+ SpecifiedValue::Specified(lang),
+ ));
+ }
+
+ Err(e) => {
+ rsvg_log!(session, "ignoring attribute with invalid value: {}", e);
+ }
+ }
}
expanded_name!(xml "space") => {
// xml:space is a non-presentation attribute and as such cannot have the
// "inherit" value. So, we don't call parse_one_presentation_attribute()
// for it, but rather call its parser directly.
- self.set_parsed_property(&ParsedProperty::XmlSpace(SpecifiedValue::Specified(
- attr.parse(value)?,
- )));
+ let parse_result: Result<XmlSpace, _> = attr.parse(value);
+ match parse_result {
+ Ok(space) => {
+ self.set_parsed_property(&ParsedProperty::XmlSpace(
+ SpecifiedValue::Specified(space),
+ ));
+ }
+
+ Err(e) => {
+ rsvg_log!(session, "ignoring attribute with invalid value: {}", e);
+ }
+ }
}
_ => self.parse_one_presentation_attribute(session, attr, value),