Bug 37787

Summary: nth-* pseudo-class parsing is incorrect
Product: WebKit Reporter: Yuzo Fujishima <yuzo>
Component: CSSAssignee: Yuzo Fujishima <yuzo>
Status: RESOLVED FIXED    
Severity: Normal    
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: PC   
OS: OS X 10.5   
Attachments:
Description Flags
Fix nth-* pseudo-class parsing. hamaji: review+

Description Yuzo Fujishima 2010-04-18 19:38:33 PDT
WebCore::CSSSelector::RareData::parseNth doesn't check whether the search for '-' in the argument was successful.
This results in incorrect parsing.
For example, '3n' is parsed as if it were '3n-3'. The code has been working OK just accidentally.
Comment 1 Yuzo Fujishima 2010-04-18 19:41:06 PDT
Created attachment 53650 [details]
Fix nth-* pseudo-class parsing.
Comment 2 Shinichiro Hamaji 2010-04-20 19:35:46 PDT
Comment on attachment 53650 [details]
Fix nth-* pseudo-class parsing.

This change looks good.

How -n-3 will be parsed, by the way? I'm not sure, but I guess it will be parsed as -n-0, right?
Comment 3 Yuzo Fujishima 2010-04-27 02:13:05 PDT
-n-3 is parsed correctly.

In determining m_b, '-' is searched by argument.find('-', 1), which finds the second '-' before '3'.
Comment 4 Yuzo Fujishima 2010-04-27 02:53:44 PDT
Committed r58300: <http://trac.webkit.org/changeset/58300>
Comment 5 Yuzo Fujishima 2010-05-17 21:53:04 PDT
The original behavior was actually incorrect and the patch did fix it.
Please see: https://bugs.webkit.org/show_bug.cgi?id=31267 .
I added tests there.