Commit d140c858 authored by hyatt@apple.com's avatar hyatt@apple.com
Browse files

https://bugs.webkit.org/show_bug.cgi?id=32045, make sure escape sequences work with

all the @-rules we support.  When escape sequences are present, the lexical scanner
just returns a generic token name: ATKEYWORD.  We have to process the escape sequences
and then recheck against the rules we support with the final processed name.  If we
find a match, we mutate the token value to the appropriate rule name token, e.g.,
NAMESPACE_SYM.

Reviewed by Dan Bernstein.

Added fast/css/namespaces/namespaces-escapes.xml

* css/CSSParser.cpp:
(WebCore::CSSParser::lex):
(WebCore::CSSParser::recheckAtKeyword):
(WebCore::CSSParser::text):
* css/CSSParser.h:



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@51600 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent f822b905
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<link rel="author" title="Anne van Kesteren" href="http://annevankesteren.nl/"/>
<link rel="author" title="Opera Software ASA" href="http://opera.com/"/>
<link rel="help" href="http://www.w3.org/TR/css3-namespace/#syntax"/>
<title>CSS Namespaces Test Suite: @namespace syntax with escapes</title>
<style>
@\N\000041 mes\pac\65 x "http://www.w3.org/1999/xhtml";
x|p { background: lime }
</style>
</head>
<body>
<p>This sentence should have a green background.</p>
</body>
</html>
4ba94e8aae64ab0d60dba2ccc018dfd5
\ No newline at end of file
layer at (0,0) size 800x600
RenderView at (0,0) size 800x600
layer at (0,0) size 800x50
RenderBlock {html} at (0,0) size 800x50
RenderBody {body} at (8,16) size 784x18
RenderBlock {p} at (0,0) size 784x18 [bgcolor=#00FF00]
RenderText {#text} at (0,0) size 299x18
text run at (0,0) width 299: "This sentence should have a green background."
2009-12-01 Dave Hyatt <hyatt@apple.com>
Reviewed by Dan Bernstein.
https://bugs.webkit.org/show_bug.cgi?id=32045, make sure escape sequences work with
all the @-rules we support. When escape sequences are present, the lexical scanner
just returns a generic token name: ATKEYWORD. We have to process the escape sequences
and then recheck against the rules we support with the final processed name. If we
find a match, we mutate the token value to the appropriate rule name token, e.g.,
NAMESPACE_SYM.
Added fast/css/namespaces/namespaces-escapes.xml
* css/CSSParser.cpp:
(WebCore::CSSParser::lex):
(WebCore::CSSParser::recheckAtKeyword):
(WebCore::CSSParser::text):
* css/CSSParser.h:
2009-12-02 Anton Muhin <antonm@chromium.org>
 
Reviewed by Adam Barth.:w
......@@ -4618,11 +4618,13 @@ static inline int yyerror(const char*) { return 1; }
int CSSParser::lex(void* yylvalWithoutType)
{
YYSTYPE* yylval = static_cast<YYSTYPE*>(yylvalWithoutType);
int token = lex();
int length;
lex();
UChar* t = text(&length);
switch (token) {
switch (token()) {
case WHITESPACE:
case SGML_CD:
case INCLUDES:
......@@ -4688,7 +4690,7 @@ int CSSParser::lex(void* yylvalWithoutType)
break;
}
return token;
return token();
}
static inline bool isCSSWhitespace(UChar c)
......@@ -4696,6 +4698,28 @@ static inline bool isCSSWhitespace(UChar c)
return c == ' ' || c == '\t' || c == '\r' || c == '\n' || c == '\f';
}
void CSSParser::recheckAtKeyword(const UChar* str, int len)
{
String ruleName(str, len);
if (equalIgnoringCase(ruleName, "@import"))
yyTok = IMPORT_SYM;
else if (equalIgnoringCase(ruleName, "@page"))
yyTok = PAGE_SYM;
else if (equalIgnoringCase(ruleName, "@media"))
yyTok = MEDIA_SYM;
else if (equalIgnoringCase(ruleName, "@font-face"))
yyTok = FONT_FACE_SYM;
else if (equalIgnoringCase(ruleName, "@charset"))
yyTok = CHARSET_SYM;
else if (equalIgnoringCase(ruleName, "@namespace"))
yyTok = NAMESPACE_SYM;
else if (equalIgnoringCase(ruleName, "@-webkit-keyframes"))
yyTok = WEBKIT_KEYFRAMES_SYM;
else if (equalIgnoringCase(ruleName, "@-webkit-mediaquery"))
yyTok = WEBKIT_MEDIAQUERY_SYM;
// FIXME: Add CSS Variables if we ever decide to turn it back on.
}
UChar* CSSParser::text(int *length)
{
UChar* start = yytext;
......@@ -4749,6 +4773,8 @@ UChar* CSSParser::text(int *length)
UChar* out = start;
UChar* escape = 0;
bool sawEscape = false;
for (int i = 0; i < l; i++) {
UChar* current = start + i;
if (escape == current - 1) {
......@@ -4793,6 +4819,7 @@ UChar* CSSParser::text(int *length)
}
if (!escape && *current == '\\') {
escape = current;
sawEscape = true;
continue;
}
*out++ = *current;
......@@ -4813,6 +4840,12 @@ UChar* CSSParser::text(int *length)
}
*length = out - start;
// If we have an unrecognized @-keyword, and if we handled any escapes at all, then
// we should attempt to adjust yyTok to the correct type.
if (yyTok == ATKEYWORD && sawEscape)
recheckAtKeyword(start, *length);
return start;
}
......
......@@ -225,6 +225,8 @@ namespace WebCore {
int lex();
private:
void recheckAtKeyword(const UChar* str, int len);
void clearProperties();
void setupParser(const char* prefix, const String&, const char* suffix);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment