Bug 564719 - SVG length parsing should indicate an error when it only contains whitespace. r=jwatt
--- a/content/svg/content/src/nsSVGLength.cpp
+++ b/content/svg/content/src/nsSVGLength.cpp
@@ -348,17 +348,17 @@ nsSVGLength::GetValueAsString(nsAString
aValueAsString.Append(nsDependentAtomString(UnitAtom));
return NS_OK;
}
NS_IMETHODIMP
nsSVGLength::SetValueAsString(const nsAString & aValueAsString)
{
- nsresult rv = NS_OK;
+ nsresult rv = NS_ERROR_DOM_SYNTAX_ERR;
char *str = ToNewCString(aValueAsString);
char* number = str;
while (*number && isspace(*number))
++number;
if (*number) {
@@ -390,25 +390,19 @@ nsSVGLength::SetValueAsString(const nsAS
else if (unitAtom == nsGkAtoms::percentage)
unitType = SVG_LENGTHTYPE_PERCENTAGE;
}
if (IsValidUnitType(unitType) && NS_FloatIsFinite(value)) {
WillModify();
mValueInSpecifiedUnits = value;
mSpecifiedUnitType = unitType;
DidModify();
- } else { // parse error
- // not a valid unit type
- rv = NS_ERROR_DOM_SYNTAX_ERR;
+ rv = NS_OK;
}
}
- else { // parse error
- // no number
- rv = NS_ERROR_DOM_SYNTAX_ERR;
- }
}
nsMemory::Free(str);
return rv;
}
/* void newValueSpecifiedUnits (in unsigned short unitType, in float valueInSpecifiedUnits); */