Changeset 73247 in webkit
- Timestamp:
- Dec 3, 2010 12:12:10 AM (13 years ago)
- Location:
- trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r73246 r73247 1 2010-12-03 Yonathan Randolph <yonathan@gmail.com> 2 3 Reviewed by Alexey Proskuryakov. 4 5 XPath lexer misinterprets expression starting with "div". 6 https://bugs.webkit.org/show_bug.cgi?id=50366 7 8 * fast/xpath/ambiguous-operators-expected.txt: Added. 9 * fast/xpath/ambiguous-operators.html: Added. 10 1 11 2010-12-02 Rob Buis <rwlbuis@gmail.com> 2 12 -
trunk/WebCore/ChangeLog
r73246 r73247 1 2010-12-03 Yonathan Randolph <yonathan@gmail.com> 2 3 Reviewed by Alexey Proskuryakov. 4 5 XPath lexer misinterprets expression starting with "div". 6 https://bugs.webkit.org/show_bug.cgi?id=50366 7 8 * xml/XPathParser.cpp: 9 * xml/XPathParser.h: 10 (WebCore::XPath::Parser::isOperatorContext): removed (renamed) 11 (WebCore::XPath::Parser::isBinaryOperatorContext): added 12 1 13 2010-12-02 Rob Buis <rwlbuis@gmail.com> 2 14 -
trunk/WebCore/xml/XPathParser.cpp
r69437 r73247 125 125 } 126 126 127 /* Returns whether the last parsed token matches the [32] Operator rule 128 * (check http://www.w3.org/TR/xpath#exprlex). Necessary to disambiguate 129 * the tokens. 130 */ 131 bool Parser::isOperatorContext() const 132 { 133 if (m_nextPos == 0) 127 // Returns whether the current token can possibly be a binary operator, given 128 // the previous token. Necessary to disambiguate some of the operators 129 // (* (multiply), div, and, or, mod) in the [32] Operator rule 130 // (check http://www.w3.org/TR/xpath#exprlex). 131 bool Parser::isBinaryOperatorContext() const 132 { 133 switch (m_lastTokenType) { 134 case 0: 135 case '@': case AXISNAME: case '(': case '[': case ',': 136 case AND: case OR: case MULOP: 137 case '/': case SLASHSLASH: case '|': case PLUS: case MINUS: 138 case EQOP: case RELOP: 134 139 return false; 135 136 switch (m_lastTokenType) { 137 case AND: case OR: case MULOP: 138 case '/': case SLASHSLASH: case '|': case PLUS: case MINUS: 139 case EQOP: case RELOP: 140 case '@': case AXISNAME: case '(': case '[': 141 return false; 142 default: 143 return true; 140 default: 141 return true; 144 142 } 145 143 } … … 280 278 char code = peekCurHelper(); 281 279 switch (code) { 282 case '(': case ')': case '[': case ']': 283 case '@': case ',': case '|': 284 return makeTokenAndAdvance(code); 285 case '\'': 286 case '\"': 287 return lexString(); 288 case '0': case '1': case '2': case '3': case '4': 289 case '5': case '6': case '7': case '8': case '9': 280 case '(': case ')': case '[': case ']': 281 case '@': case ',': case '|': 282 return makeTokenAndAdvance(code); 283 case '\'': 284 case '\"': 285 return lexString(); 286 case '0': case '1': case '2': case '3': case '4': 287 case '5': case '6': case '7': case '8': case '9': 288 return lexNumber(); 289 case '.': { 290 char next = peekAheadHelper(); 291 if (next == '.') 292 return makeTokenAndAdvance(DOTDOT, 2); 293 if (next >= '0' && next <= '9') 290 294 return lexNumber(); 291 case '.': { 292 char next = peekAheadHelper(); 293 if (next == '.') 294 return makeTokenAndAdvance(DOTDOT, 2); 295 if (next >= '0' && next <= '9') 296 return lexNumber(); 297 return makeTokenAndAdvance('.'); 298 } 299 case '/': 300 if (peekAheadHelper() == '/') 301 return makeTokenAndAdvance(SLASHSLASH, 2); 302 return makeTokenAndAdvance('/'); 303 case '+': 304 return makeTokenAndAdvance(PLUS); 305 case '-': 306 return makeTokenAndAdvance(MINUS); 307 case '=': 308 return makeTokenAndAdvance(EQOP, EqTestOp::OP_EQ); 309 case '!': 310 if (peekAheadHelper() == '=') 311 return makeTokenAndAdvance(EQOP, EqTestOp::OP_NE, 2); 295 return makeTokenAndAdvance('.'); 296 } 297 case '/': 298 if (peekAheadHelper() == '/') 299 return makeTokenAndAdvance(SLASHSLASH, 2); 300 return makeTokenAndAdvance('/'); 301 case '+': 302 return makeTokenAndAdvance(PLUS); 303 case '-': 304 return makeTokenAndAdvance(MINUS); 305 case '=': 306 return makeTokenAndAdvance(EQOP, EqTestOp::OP_EQ); 307 case '!': 308 if (peekAheadHelper() == '=') 309 return makeTokenAndAdvance(EQOP, EqTestOp::OP_NE, 2); 310 return Token(XPATH_ERROR); 311 case '<': 312 if (peekAheadHelper() == '=') 313 return makeTokenAndAdvance(RELOP, EqTestOp::OP_LE, 2); 314 return makeTokenAndAdvance(RELOP, EqTestOp::OP_LT); 315 case '>': 316 if (peekAheadHelper() == '=') 317 return makeTokenAndAdvance(RELOP, EqTestOp::OP_GE, 2); 318 return makeTokenAndAdvance(RELOP, EqTestOp::OP_GT); 319 case '*': 320 if (isBinaryOperatorContext()) 321 return makeTokenAndAdvance(MULOP, NumericOp::OP_Mul); 322 ++m_nextPos; 323 return Token(NAMETEST, "*"); 324 case '$': { // $ QName 325 m_nextPos++; 326 String name; 327 if (!lexQName(name)) 312 328 return Token(XPATH_ERROR); 313 case '<': 314 if (peekAheadHelper() == '=') 315 return makeTokenAndAdvance(RELOP, EqTestOp::OP_LE, 2); 316 return makeTokenAndAdvance(RELOP, EqTestOp::OP_LT); 317 case '>': 318 if (peekAheadHelper() == '=') 319 return makeTokenAndAdvance(RELOP, EqTestOp::OP_GE, 2); 320 return makeTokenAndAdvance(RELOP, EqTestOp::OP_GT); 321 case '*': 322 if (isOperatorContext()) 323 return makeTokenAndAdvance(MULOP, NumericOp::OP_Mul); 324 ++m_nextPos; 325 return Token(NAMETEST, "*"); 326 case '$': { // $ QName 327 m_nextPos++; 328 String name; 329 if (!lexQName(name)) 330 return Token(XPATH_ERROR); 331 return Token(VARIABLEREFERENCE, name); 332 } 329 return Token(VARIABLEREFERENCE, name); 330 } 333 331 } 334 332 … … 339 337 skipWS(); 340 338 // If we're in an operator context, check for any operator names 341 if (is OperatorContext()) {339 if (isBinaryOperatorContext()) { 342 340 if (name == "and") //### hash? 343 341 return Token(AND); … … 431 429 432 430 switch (tok.type) { 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 431 case AXISNAME: 432 yylval->axis = tok.axis; 433 break; 434 case MULOP: 435 yylval->numop = tok.numop; 436 break; 437 case RELOP: 438 case EQOP: 439 yylval->eqop = tok.eqop; 440 break; 441 case NODETYPE: 442 case PI: 443 case FUNCTIONNAME: 444 case LITERAL: 445 case VARIABLEREFERENCE: 446 case NUMBER: 447 case NAMETEST: 448 yylval->str = new String(tok.str); 449 registerString(yylval->str); 450 break; 453 451 } 454 452 -
trunk/WebCore/xml/XPathParser.h
r69437 r73247 92 92 93 93 private: 94 bool is OperatorContext() const;94 bool isBinaryOperatorContext() const; 95 95 96 96 void skipWS();
Note: See TracChangeset
for help on using the changeset viewer.