[librsvg] (#481): Length::parse() - don't expect_exhausted()



commit b53df7d86930ad4391cd858a16e1cf0149885936
Author: Federico Mena Quintero <federico gnome org>
Date:   Mon Jul 1 13:44:51 2019 -0500

    (#481): Length::parse() - don't expect_exhausted()
    
    This makes me somewhat concerned, since it means that somewhere in the
    callers we should probably do expect_exhausted(), but we aren't doing
    it currently.
    
    The specific problem here is that in an SVG with
    
      <tspan x="2209 2903 3394 3792 4190 4626 5117" y="18611" id="tspan1053">Current</tspan>
    
    i.e. a tspan with multiple positions in the "x" attribute, the whole
    attribute yields a parse error because there is extra stuff after the
    initial 2209.
    
    While the text-related elements should realy parse a list of Length
    for their x/y/dx/dy attributes, we'll use this little hack for now:
    let there be extra data after a length value, so at least the first
    value goes through.
    
    Fixes https://gitlab.gnome.org/GNOME/librsvg/issues/481

 rsvg_internals/src/length.rs                             |   6 +-----
 .../bugs/481-tspan-uses-at-least-first-x-ref.png         | Bin 0 -> 1002 bytes
 .../reftests/bugs/481-tspan-uses-at-least-first-x.svg    |  15 +++++++++++++++
 3 files changed, 16 insertions(+), 5 deletions(-)
---
diff --git a/rsvg_internals/src/length.rs b/rsvg_internals/src/length.rs
index 6c744277..7d6d95eb 100644
--- a/rsvg_internals/src/length.rs
+++ b/rsvg_internals/src/length.rs
@@ -208,11 +208,7 @@ impl Parse for Length {
     type Err = ValueErrorKind;
 
     fn parse(parser: &mut Parser<'_, '_>) -> Result<Length, ValueErrorKind> {
-        let length = Length::from_cssparser(parser)?;
-
-        parser.expect_exhausted().map_err(|_| make_err())?;
-
-        Ok(length)
+        Length::from_cssparser(parser)
     }
 }
 
diff --git a/tests/fixtures/reftests/bugs/481-tspan-uses-at-least-first-x-ref.png 
b/tests/fixtures/reftests/bugs/481-tspan-uses-at-least-first-x-ref.png
new file mode 100644
index 00000000..19b51155
Binary files /dev/null and b/tests/fixtures/reftests/bugs/481-tspan-uses-at-least-first-x-ref.png differ
diff --git a/tests/fixtures/reftests/bugs/481-tspan-uses-at-least-first-x.svg 
b/tests/fixtures/reftests/bugs/481-tspan-uses-at-least-first-x.svg
new file mode 100644
index 00000000..7c7ed4a3
--- /dev/null
+++ b/tests/fixtures/reftests/bugs/481-tspan-uses-at-least-first-x.svg
@@ -0,0 +1,15 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg"; width="200" height="200">
+  <!--
+    As of July 2019, librsvg does not support multiple positions in
+    the x/y/dx/dy attributes of text/tspan elements.  This test is to
+    check that the library at least uses the first position specified.
+
+    (The reference PNG for this SVG is incorrect with respect to the
+    spec, since we don't actually use the second and third positions;
+    it's as if the "Foo" had normal letter spacing.)
+  -->
+  <text style="font-family: sans; font-size: 50; fill: black;" y="100">
+    <tspan x="70 120 170">Foo</tspan>
+  </text>
+</svg>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]