Index: Source/core/svg/SVGAngle.cpp |
diff --git a/Source/core/svg/SVGAngle.cpp b/Source/core/svg/SVGAngle.cpp |
index 7e91ef5049b310d911a361c838d39a01af558d6f..7768b9385ceb1bfb713a3631cf552d7a9b04e172 100644 |
--- a/Source/core/svg/SVGAngle.cpp |
+++ b/Source/core/svg/SVGAngle.cpp |
@@ -152,35 +152,27 @@ static SVGAngle::SVGAngleType stringToAngleType(const CharType*& ptr, const Char |
if (ptr == end) |
return SVGAngle::SVG_ANGLETYPE_UNSPECIFIED; |
- const CharType firstChar = *ptr; |
- |
- // If the unit contains only one character, the angle type is unknown. |
- ++ptr; |
- if (ptr == end) |
- return SVGAngle::SVG_ANGLETYPE_UNKNOWN; |
- |
- const CharType secondChar = *ptr; |
- |
- // If the unit contains only two characters, the angle type is unknown. |
- ++ptr; |
- if (ptr == end) |
- return SVGAngle::SVG_ANGLETYPE_UNKNOWN; |
- |
- const CharType thirdChar = *ptr; |
- if (firstChar == 'd' && secondChar == 'e' && thirdChar == 'g') |
- return SVGAngle::SVG_ANGLETYPE_DEG; |
- if (firstChar == 'r' && secondChar == 'a' && thirdChar == 'd') |
- return SVGAngle::SVG_ANGLETYPE_RAD; |
- |
- // If the unit contains three characters, but is not deg or rad, then it's unknown. |
- ++ptr; |
- if (ptr == end) |
- return SVGAngle::SVG_ANGLETYPE_UNKNOWN; |
- |
- const CharType fourthChar = *ptr; |
+ SVGAngle::SVGAngleType type = SVGAngle::SVG_ANGLETYPE_UNKNOWN; |
+ const CharType firstChar = *ptr++; |
+ |
+ if (isHTMLSpace<CharType>(firstChar)) { |
+ type = SVGAngle::SVG_ANGLETYPE_UNSPECIFIED; |
+ } else if (end - ptr >= 2) { |
+ const CharType secondChar = *ptr++; |
+ const CharType thirdChar = *ptr++; |
+ if (firstChar == 'd' && secondChar == 'e' && thirdChar == 'g') { |
+ type = SVGAngle::SVG_ANGLETYPE_DEG; |
+ } else if (firstChar == 'r' && secondChar == 'a' && thirdChar == 'd') { |
+ type = SVGAngle::SVG_ANGLETYPE_RAD; |
+ } else if (ptr != end) { |
+ const CharType fourthChar = *ptr++; |
+ if (firstChar == 'g' && secondChar == 'r' && thirdChar == 'a' && fourthChar == 'd') |
+ type = SVGAngle::SVG_ANGLETYPE_GRAD; |
+ } |
+ } |
- if (firstChar == 'g' && secondChar == 'r' && thirdChar == 'a' && fourthChar == 'd') |
- return SVGAngle::SVG_ANGLETYPE_GRAD; |
+ if (!skipOptionalSVGSpaces(ptr, end)) |
+ return type; |
return SVGAngle::SVG_ANGLETYPE_UNKNOWN; |
} |
@@ -215,7 +207,7 @@ static bool parseValue(const String& value, float& valueInSpecifiedUnits, SVGAng |
const CharType* ptr = value.getCharacters<CharType>(); |
const CharType* end = ptr + value.length(); |
- if (!parseNumber(ptr, end, valueInSpecifiedUnits, false)) |
+ if (!parseNumber(ptr, end, valueInSpecifiedUnits, AllowLeadingWhitespace)) |
return false; |
unitType = stringToAngleType(ptr, end); |