mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 399642 - "Make parsing stricter" [p=longsonr@gmail.com (Robert Longson) r=tor sr+a1.9=roc]
This commit is contained in:
parent
d3fd192a81
commit
a85b754e08
@ -184,28 +184,22 @@ GetValueFromString(const nsAString &aValueAsString,
|
||||
float *aValue,
|
||||
PRUint16 *aUnitType)
|
||||
{
|
||||
char *str = ToNewCString(aValueAsString);
|
||||
if (!str)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ConvertUTF16toUTF8 value(aValueAsString);
|
||||
const char *str = value.get();
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
if (NS_IsAsciiWhitespace(*str))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (*str) {
|
||||
char *rest;
|
||||
*aValue = static_cast<float>(PR_strtod(str, &rest));
|
||||
if (rest != str) {
|
||||
*aUnitType = GetUnitTypeForString(nsCRT::strtok(rest,
|
||||
"\x20\x9\xD\xA",
|
||||
&rest));
|
||||
if (IsValidUnitType(*aUnitType)) {
|
||||
rv = NS_OK;
|
||||
}
|
||||
char *rest;
|
||||
*aValue = float(PR_strtod(str, &rest));
|
||||
if (rest != str) {
|
||||
*aUnitType = GetUnitTypeForString(rest);
|
||||
if (IsValidUnitType(*aUnitType)) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsMemory::Free(str);
|
||||
|
||||
return rv;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
float
|
||||
|
@ -52,12 +52,18 @@ nsSVGInteger::SetBaseValueString(const nsAString &aValueAsString,
|
||||
nsSVGElement *aSVGElement,
|
||||
PRBool aDoSetAttr)
|
||||
{
|
||||
nsAutoString s;
|
||||
s.Assign(aValueAsString);
|
||||
PRInt32 err;
|
||||
PRInt32 val = s.ToInteger(&err);
|
||||
nsresult rv = static_cast<nsresult>(err);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ConvertUTF16toUTF8 value(aValueAsString);
|
||||
const char *str = value.get();
|
||||
|
||||
if (NS_IsAsciiWhitespace(*str))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
char *rest;
|
||||
PRInt32 val = strtol(str, &rest, 10);
|
||||
if (rest == str || *rest != '\0') {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mBaseVal = mAnimVal = val;
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -145,28 +145,22 @@ GetValueFromString(const nsAString &aValueAsString,
|
||||
float *aValue,
|
||||
PRUint16 *aUnitType)
|
||||
{
|
||||
char *str = ToNewCString(aValueAsString);
|
||||
if (!str)
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
NS_ConvertUTF16toUTF8 value(aValueAsString);
|
||||
const char *str = value.get();
|
||||
|
||||
nsresult rv = NS_ERROR_FAILURE;
|
||||
if (NS_IsAsciiWhitespace(*str))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
if (*str) {
|
||||
char *rest;
|
||||
*aValue = static_cast<float>(PR_strtod(str, &rest));
|
||||
if (rest != str) {
|
||||
*aUnitType = GetUnitTypeForString(nsCRT::strtok(rest,
|
||||
"\x20\x9\xD\xA",
|
||||
&rest));
|
||||
if (IsValidUnitType(*aUnitType)) {
|
||||
rv = NS_OK;
|
||||
}
|
||||
char *rest;
|
||||
*aValue = float(PR_strtod(str, &rest));
|
||||
if (rest != str) {
|
||||
*aUnitType = GetUnitTypeForString(rest);
|
||||
if (IsValidUnitType(*aUnitType)) {
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
nsMemory::Free(str);
|
||||
|
||||
return rv;
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
float
|
||||
|
@ -54,12 +54,18 @@ nsSVGNumber2::SetBaseValueString(const nsAString &aValueAsString,
|
||||
nsSVGElement *aSVGElement,
|
||||
PRBool aDoSetAttr)
|
||||
{
|
||||
nsAutoString s;
|
||||
s.Assign(aValueAsString);
|
||||
PRInt32 err;
|
||||
float val = s.ToFloat(&err);
|
||||
nsresult rv = static_cast<nsresult>(err);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ConvertUTF16toUTF8 value(aValueAsString);
|
||||
const char *str = value.get();
|
||||
|
||||
if (NS_IsAsciiWhitespace(*str))
|
||||
return NS_ERROR_FAILURE;
|
||||
|
||||
char *rest;
|
||||
float val = float(PR_strtod(str, &rest));
|
||||
if (rest == str || *rest != '\0') {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
mBaseVal = mAnimVal = val;
|
||||
return NS_OK;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user