Bug 564719 - SVG length parsing should indicate an error when it only contains whitespace. r=jwatt
authorRobert Longson <longsonr@gmail.com>
Fri, 28 May 2010 12:07:06 +0100
changeset 42892 cb8e43571769353f32bb3dae35e9fc4671283ddf
parent 42891 aa20e4f73d81e5cf9e7f2efb5f0e7b73084a24f2
child 42893 b307f4eb573b26f39683891701e27970dda3baa0
push idunknown
push userunknown
push dateunknown
reviewersjwatt
bugs564719
milestone1.9.3a5pre
Bug 564719 - SVG length parsing should indicate an error when it only contains whitespace. r=jwatt
content/svg/content/src/nsSVGLength.cpp
--- 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); */