[librsvg/rustification] rsvg-path: Make the path parser stop when there is an invalid character



commit 186418e2b84013ff377175d0c143b64896f91dd0
Author: Federico Mena Quintero <federico gnome org>
Date:   Thu Nov 3 15:06:13 2016 -0600

    rsvg-path: Make the path parser stop when there is an invalid character
    
    This per the spec.
    
    This makes the test fixtures/reftests/svg1.1/paths-data-18-f.svg pass; it failed previously.
    
    The parser still does not follow the BNF specified in the spec; we should
    do that at some point.

 rsvg-path.c                                        |    6 +++++-
 .../reftests/svg1.1/paths-data-18-f-ref.png        |  Bin 4691 -> 4837 bytes
 2 files changed, 5 insertions(+), 1 deletions(-)
---
diff --git a/rsvg-path.c b/rsvg-path.c
index d37a5a2..9901425 100644
--- a/rsvg-path.c
+++ b/rsvg-path.c
@@ -455,8 +455,12 @@ rsvg_parse_path_data (RSVGParsePathCtx * ctx, const char *data)
                 rsvg_parse_path_do_cmd (ctx, TRUE);
             ctx->cmd = c;
             ctx->rel = TRUE;
+        } else if (g_ascii_isspace (c)) {
+        } else if (c == ',') {
+        } else {
+            ctx->param = 0;
+            break; /* all other characters are an error */
         }
-        /* else c _should_ be whitespace or , */
     }
 }
 
diff --git a/tests/fixtures/reftests/svg1.1/paths-data-18-f-ref.png 
b/tests/fixtures/reftests/svg1.1/paths-data-18-f-ref.png
index a2e2e74..1259600 100644
Binary files a/tests/fixtures/reftests/svg1.1/paths-data-18-f-ref.png and 
b/tests/fixtures/reftests/svg1.1/paths-data-18-f-ref.png differ


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