From bbc129fb45ed684192cfc4ea7ffa2e7d9c56ba3e Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 17 Sep 2015 10:49:43 +0100 Subject: [PATCH] Fix for SVG parsing of paths containing non-space-separated decimal points --- .../drawables/juce_SVGParser.cpp | 20 +++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp index e5653df014..01d487228f 100644 --- a/modules/juce_gui_basics/drawables/juce_SVGParser.cpp +++ b/modules/juce_gui_basics/drawables/juce_SVGParser.cpp @@ -1091,6 +1091,11 @@ private: } //============================================================================== + static bool isStartOfNumber (juce_wchar c) noexcept + { + return CharacterFunctions::isDigit (c) || c == '-' || c == '+'; + } + static bool parseNextNumber (String::CharPointerType& text, String& value, const bool allowUnits) { String::CharPointerType s (text); @@ -1100,14 +1105,21 @@ private: String::CharPointerType start (s); - if (s.isDigit() || *s == '.' || *s == '-') + if (isStartOfNumber (*s)) ++s; - while (s.isDigit() || *s == '.') + while (s.isDigit()) ++s; - if ((*s == 'e' || *s == 'E') - && ((s + 1).isDigit() || s[1] == '-' || s[1] == '+')) + if (*s == '.') + { + ++s; + + while (s.isDigit()) + ++s; + } + + if ((*s == 'e' || *s == 'E') && isStartOfNumber (s[1])) { s += 2;