Bug 37787 - nth-* pseudo-class parsing is incorrect
Summary: nth-* pseudo-class parsing is incorrect
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: PC OS X 10.5
: P2 Normal
Assignee: Yuzo Fujishima
Depends on:
Reported: 2010-04-18 19:38 PDT by Yuzo Fujishima
Modified: 2010-05-17 21:53 PDT (History)
0 users

See Also:

Fix nth-* pseudo-class parsing. (1.44 KB, patch)
2010-04-18 19:41 PDT, Yuzo Fujishima
hamaji: review+
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
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.