Chromium Code Reviews| Index: Source/core/svg/SVGAnimationElement.cpp |
| diff --git a/Source/core/svg/SVGAnimationElement.cpp b/Source/core/svg/SVGAnimationElement.cpp |
| index a6681158c25c49ec0be2515c7ba144c262f7b72a..834db8c6a9941c1316c7cf5d291688e06caf7bfe 100644 |
| --- a/Source/core/svg/SVGAnimationElement.cpp |
| +++ b/Source/core/svg/SVGAnimationElement.cpp |
| @@ -52,11 +52,11 @@ SVGAnimationElement::SVGAnimationElement(const QualifiedName& tagName, Document& |
| UseCounter::count(document, UseCounter::SVGAnimationElement); |
| } |
| -static void parseKeyTimes(const String& string, Vector<float>& result, bool verifyOrder) |
| +static bool parseKeyTimes(const String& string, Vector<float>& result, bool verifyOrder) |
| { |
| result.clear(); |
| Vector<String> parseList; |
| - string.split(';', parseList); |
| + string.split(';', true, parseList); |
| for (unsigned n = 0; n < parseList.size(); ++n) { |
| String timeString = parseList[n]; |
| bool ok; |
| @@ -72,9 +72,10 @@ static void parseKeyTimes(const String& string, Vector<float>& result, bool veri |
| } |
| result.append(time); |
| } |
| - return; |
| + return true; |
| fail: |
| result.clear(); |
| + return false; |
| } |
| template<typename CharType> |
| @@ -165,16 +166,30 @@ void SVGAnimationElement::parseAttribute(const QualifiedName& name, const Atomic |
| // Per the SMIL specification, leading and trailing white space, |
| // and white space before and after semicolon separators, is allowed and will be ignored. |
| // http://www.w3.org/TR/SVG11/animate.html#ValuesAttribute |
| - value.string().split(';', m_values); |
| - for (unsigned i = 0; i < m_values.size(); ++i) |
| - m_values[i] = m_values[i].stripWhiteSpace(); |
| + Vector<String> parseList; |
|
fs
2014/09/22 10:26:28
Maybe move this lot into a function now that it's
|
| + value.string().split(';', true, parseList); |
| + unsigned last = parseList.size() - 1; |
| + for (unsigned i = 0; i <= last; ++i) { |
| + parseList[i] = parseList[i].stripWhiteSpace(); |
| + if (parseList[i].isEmpty()) { |
| + // Tolerate trailing ';' |
| + if (i < last) { |
| + m_values.clear(); |
| + reportAttributeParsingError(ParsingAttributeFailedError, name, value); |
|
fs
2014/09/22 10:26:28
Please add a test for a 'values' for an attribute
|
| + return; |
| + } |
| + } else { |
| + m_values.append(parseList[i]); |
| + } |
| + } |
| updateAnimationMode(); |
| return; |
| } |
| if (name == SVGNames::keyTimesAttr) { |
| - parseKeyTimes(value, m_keyTimes, true); |
| + if (!parseKeyTimes(value, m_keyTimes, true)) |
| + reportAttributeParsingError(ParsingAttributeFailedError, name, value); |
| return; |
| } |
| @@ -182,7 +197,8 @@ void SVGAnimationElement::parseAttribute(const QualifiedName& name, const Atomic |
| if (isSVGAnimateMotionElement(*this)) { |
| // This is specified to be an animateMotion attribute only but it is simpler to put it here |
| // where the other timing calculatations are. |
| - parseKeyTimes(value, m_keyPoints, false); |
| + if (!parseKeyTimes(value, m_keyPoints, false)) |
| + reportAttributeParsingError(ParsingAttributeFailedError, name, value); |
| } |
| return; |
| } |