From 185007f906162a3df9b46616379fb7e2939ed7d4 Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 31 Aug 2011 18:09:58 -0400 Subject: [PATCH] Bug 679689. Allow empty string values to be associtated to enumerated attributes. r=sicking --- content/base/crashtests/679689-1.html | 2 ++ content/base/crashtests/crashtests.list | 1 + content/base/src/nsAttrValue.cpp | 10 +++++++--- 3 files changed, 10 insertions(+), 3 deletions(-) create mode 100644 content/base/crashtests/679689-1.html diff --git a/content/base/crashtests/679689-1.html b/content/base/crashtests/679689-1.html new file mode 100644 index 00000000000..aab88bbc363 --- /dev/null +++ b/content/base/crashtests/679689-1.html @@ -0,0 +1,2 @@ + + diff --git a/content/base/crashtests/crashtests.list b/content/base/crashtests/crashtests.list index 0291bcc0953..5a2a9ecc698 100644 --- a/content/base/crashtests/crashtests.list +++ b/content/base/crashtests/crashtests.list @@ -93,3 +93,4 @@ load 642022-1.html load 646184.html load 658845-1.svg load 667336-1.html +load 679689-1.html diff --git a/content/base/src/nsAttrValue.cpp b/content/base/src/nsAttrValue.cpp index 70ce9bd49be..988097f875e 100644 --- a/content/base/src/nsAttrValue.cpp +++ b/content/base/src/nsAttrValue.cpp @@ -1250,10 +1250,14 @@ nsAttrValue::SetMiscAtomOrString(const nsAString* aValue) "Trying to re-set atom or string!"); if (aValue) { PRUint32 len = aValue->Length(); - // We're allowing eCSSStyleRule attributes to store empty strings as it - // can be beneficial to store an empty style attribute as a parsed rule. + // * We're allowing eCSSStyleRule attributes to store empty strings as it + // can be beneficial to store an empty style attribute as a parsed rule. + // * We're allowing enumerated values because sometimes the empty + // string corresponds to a particular enumerated value, especially + // for enumerated values that are not limited enumerated. // Add other types as needed. - NS_ASSERTION(len || Type() == eCSSStyleRule, "Empty string?"); + NS_ASSERTION(len || Type() == eCSSStyleRule || Type() == eEnum, + "Empty string?"); MiscContainer* cont = GetMiscContainer(); if (len <= NS_ATTRVALUE_MAX_STRINGLENGTH_ATOM) { nsIAtom* atom = NS_NewAtom(*aValue);