Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1483)

Unified Diff: Source/core/svg/SVGAnimationElement.cpp

Issue 584053002: Handle semicolons at end of keyTimes and values (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/svg/custom/script-tests/keyTimes-parsing-error.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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;
}
« no previous file with comments | « LayoutTests/svg/custom/script-tests/keyTimes-parsing-error.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698