[Webkit-unassigned] [Bug 70107] Custom written CSS lexer

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Tue Dec 13 00:04:37 PST 2011


https://bugs.webkit.org/show_bug.cgi?id=70107





--- Comment #21 from Zoltan Herczeg <zherczeg at webkit.org>  2011-12-13 00:04:36 PST ---
> > Source/WebCore/css/CSSParser.cpp:7388
> > +    return chr | 0x20;
> 
> Can you add an assertion that chr is in fact an ascii letter?

It doesn't need to be one. I saw this trick in JavaScriptCore/wtf/ASCIICType.h

(chr | 0x20) == 'a' if and only if chr is 'A' or 'a'. Nothing else can satisfy this expression, and I use it for character comparison many times.

The only exception is the second isCaselessEqual, where I describe the rules applies to that function in the comment, and assertions were added to check the rules. Basically if constantString contains minus sign '-', the cssString must contains only cssLetter-s.

> 
> > Source/WebCore/css/CSSParser.cpp:7394
> > +        || (data[0] == '\\' && isCSSEscape(data[1]));
> 
> How do we guarantee data is at least 2 characters long?

C++ has a short circuit expression evaluation method, so data[0] == '\\' must be true before it checks data[1].

> Can you explain to me how the quoted string lexing doesn't run off the end of the buffer though?  I still can't see it.

You are right here, checkString must return with fail if it encounters a \0.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list