[librsvg/librsvg-2.50] Detect empty strings as invalid in FilterValueList::parse
- From: Federico Mena Quintero <federico src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [librsvg/librsvg-2.50] Detect empty strings as invalid in FilterValueList::parse
- Date: Fri, 2 Oct 2020 19:24:35 +0000 (UTC)
commit 308d8c04350a989db6c4eaa3b18845dff9c0543a
Author: Federico Mena Quintero <federico gnome org>
Date: Wed Sep 9 10:43:37 2020 -0500
Detect empty strings as invalid in FilterValueList::parse
The spec allows "none | <filter-value-list>" and the latter cannot be empty.
rsvg_internals/src/filter.rs | 16 +++++++++++-----
1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/rsvg_internals/src/filter.rs b/rsvg_internals/src/filter.rs
index 1553763e..6af6a9d2 100644
--- a/rsvg_internals/src/filter.rs
+++ b/rsvg_internals/src/filter.rs
@@ -257,14 +257,19 @@ impl Parse for FilterValueList {
return Ok(result);
}
- while !parser.is_exhausted() {
- let loc = parser.current_source_location();
+ loop {
+ let state = parser.state();
- if let Ok(IRI::Resource(uri)) = IRI::parse(parser) {
+ if let Ok(IRI::Resource(uri)) = parser.try_parse(|p| IRI::parse(p)) {
result.0.push(FilterValue::URL(uri));
} else {
- let token = parser.next()?;
- return Err(loc.new_basic_unexpected_token_error(token.clone()).into());
+ parser.reset(&state);
+ let token = parser.next()?.clone();
+ return Err(parser.new_basic_unexpected_token_error(token).into());
+ }
+
+ if parser.is_exhausted() {
+ break;
}
}
@@ -296,6 +301,7 @@ mod tests {
#[test]
fn detects_invalid_filter_value_list() {
+ assert!(FilterValueList::parse_str("").is_err());
assert!(FilterValueList::parse_str("fail").is_err());
assert!(FilterValueList::parse_str("url(#test) none").is_err());
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]