Don't allow pseudos that are supposed to be functions to pass through as ident

tokens.  Bug 230704, r+sr=dbaron
This commit is contained in:
bzbarsky%mit.edu 2004-01-12 23:56:18 +00:00
Родитель f2c4812c7e
Коммит 04b733ce1c
2 изменённых файлов: 30 добавлений и 12 удалений

Просмотреть файл

@ -2154,20 +2154,29 @@ void CSSParserImpl::ParsePseudoSelector(PRInt32& aDataMask,
// stash away some info about this pseudo so we only have to get it once. // stash away some info about this pseudo so we only have to get it once.
#ifdef MOZ_XUL #ifdef MOZ_XUL
// If a tree pseudo-element is using the function syntax, it will
// get isTree set here and will pass the check below that only
// allows functions if they are in our list of things allowed to be
// functions. If it is _not_ using the function syntax, isTree will
// be false, and it will still pass that check. So the tree
// pseudo-elements are allowed to be either functions or not, as
// desired.
PRBool isTree = (eCSSToken_Function == mToken.mType) && PRBool isTree = (eCSSToken_Function == mToken.mType) &&
IsTreePseudoElement(pseudo); IsTreePseudoElement(pseudo);
#endif #endif
PRBool isPseudoElement = nsCSSPseudoElements::IsPseudoElement(pseudo); PRBool isPseudoElement = nsCSSPseudoElements::IsPseudoElement(pseudo);
PRBool isAnonBox = nsCSSAnonBoxes::IsAnonBox(pseudo); PRBool isAnonBox = nsCSSAnonBoxes::IsAnonBox(pseudo);
// If it's a function token, it better be on our "ok" list // If it's a function token, it better be on our "ok" list, and if the name
if (eCSSToken_Function == mToken.mType && // is that of a function pseudo it better be a function token
if ((eCSSToken_Function == mToken.mType) !=
(
#ifdef MOZ_XUL #ifdef MOZ_XUL
!isTree && isTree ||
#endif #endif
nsCSSPseudoClasses::notPseudo != pseudo && nsCSSPseudoClasses::notPseudo == pseudo ||
nsCSSPseudoClasses::lang != pseudo) { // There are no other function pseudos nsCSSPseudoClasses::lang == pseudo)) { // There are no other function pseudos
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected identifier for function pseudo-class or pseudo-element but found")); REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Function token for non-function pseudo-class or pseudo-element, or the other way around, when reading"));
UngetToken(); UngetToken();
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR; aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
return; return;

Просмотреть файл

@ -2154,20 +2154,29 @@ void CSSParserImpl::ParsePseudoSelector(PRInt32& aDataMask,
// stash away some info about this pseudo so we only have to get it once. // stash away some info about this pseudo so we only have to get it once.
#ifdef MOZ_XUL #ifdef MOZ_XUL
// If a tree pseudo-element is using the function syntax, it will
// get isTree set here and will pass the check below that only
// allows functions if they are in our list of things allowed to be
// functions. If it is _not_ using the function syntax, isTree will
// be false, and it will still pass that check. So the tree
// pseudo-elements are allowed to be either functions or not, as
// desired.
PRBool isTree = (eCSSToken_Function == mToken.mType) && PRBool isTree = (eCSSToken_Function == mToken.mType) &&
IsTreePseudoElement(pseudo); IsTreePseudoElement(pseudo);
#endif #endif
PRBool isPseudoElement = nsCSSPseudoElements::IsPseudoElement(pseudo); PRBool isPseudoElement = nsCSSPseudoElements::IsPseudoElement(pseudo);
PRBool isAnonBox = nsCSSAnonBoxes::IsAnonBox(pseudo); PRBool isAnonBox = nsCSSAnonBoxes::IsAnonBox(pseudo);
// If it's a function token, it better be on our "ok" list // If it's a function token, it better be on our "ok" list, and if the name
if (eCSSToken_Function == mToken.mType && // is that of a function pseudo it better be a function token
if ((eCSSToken_Function == mToken.mType) !=
(
#ifdef MOZ_XUL #ifdef MOZ_XUL
!isTree && isTree ||
#endif #endif
nsCSSPseudoClasses::notPseudo != pseudo && nsCSSPseudoClasses::notPseudo == pseudo ||
nsCSSPseudoClasses::lang != pseudo) { // There are no other function pseudos nsCSSPseudoClasses::lang == pseudo)) { // There are no other function pseudos
REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Expected identifier for function pseudo-class or pseudo-element but found")); REPORT_UNEXPECTED_TOKEN(NS_LITERAL_STRING("Function token for non-function pseudo-class or pseudo-element, or the other way around, when reading"));
UngetToken(); UngetToken();
aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR; aParsingStatus = SELECTOR_PARSING_STOPPED_ERROR;
return; return;