Bug 142167

Summary: querySelectorAll throws SyntaxError for attribute selector with missing ']'
Product: WebKit Reporter: C Snover <bugs.webkit.org>
Component: CSSAssignee: Emilio Cobos Álvarez (:emilio) <emilio>
Status: RESOLVED FIXED    
Severity: Normal CC: annevk, benjamin, cdumez, commit-queue, emilio, enmi.lee, ews-watchlist, koivisto, rniwa, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch
none
Archive of layout-test-results from ews102 for mac-highsierra
none
Archive of layout-test-results from ews107 for mac-highsierra-wk2
none
Archive of layout-test-results from ews201 for win-future
none
Archive of layout-test-results from ews115 for mac-highsierra
none
Archive of layout-test-results from ews125 for ios-simulator-wk2
none
Patch none

Description C Snover 2015-03-02 08:35:41 PST
Steps to reproduce:

1. http://jsfiddle.net/k0wfsv3f/

Expected results: Displays PASS

Actual results: Displays Error: SyntaxError: DOM Exception 12

Chrome 40: PASS
IE 11: PASS
Saf 8: FAIL
Saf 7: FAIL
Firefox 38: FAIL (patch available)

More information: https://code.google.com/p/chromium/issues/detail?id=460399#c6
Related Web compat issue: https://github.com/webcompat/web-bugs/issues/676
Related Mozilla bug: https://bugzilla.mozilla.org/show_bug.cgi?id=1137984
Comment 1 Anne van Kesteren 2018-01-08 08:04:16 PST
https://github.com/w3c/web-platform-tests/pull/8951 makes sure this is covered by web-platform-tests.
Comment 2 Emilio Cobos Álvarez (:emilio) 2019-02-27 22:56:07 PST
FWIW, spec text:

https://drafts.csswg.org/css-syntax/#parse-error:

> Certain points in the parsing algorithm are said to be parse errors. The error handling for parse errors is well-defined: user agents must either act as described below when encountering such problems, or must abort processing at the first error that they encounter for which they do not wish to apply the rules described below.

https://drafts.csswg.org/css-syntax/#consume-simple-block:

> <EOF-token>
>   This is a parse error. Return the block.

(So the block is returned, and thus auto-closed)

Same happens on `data:text/html,<style>:root { background: rgb(0, 255, 0`, where all browsers do the right thing.

I guess Safari is not technically non-compliant, in the sense that they're technically "abort processing at the first error that they encounter for which they do not wish to apply the rules described below", but...
Comment 3 Emilio Cobos Álvarez (:emilio) 2019-03-31 17:55:38 PDT
This is trivial to fix. I'll give it a shot as soon as my WebKit build finishes... :)

http://webkit.crisal.io/webkit/rev/6cc00baaf9835dc4abdf7b16e72cff60ecd7bb88/Source/WebCore/css/parser/CSSSelectorParser.cpp#402
Comment 4 Emilio Cobos Álvarez (:emilio) 2019-03-31 17:57:37 PDT
Well actually my WebKit build fails in some random GTK dependency... I guess it's EWS-based test updates then :)
Comment 5 Emilio Cobos Álvarez (:emilio) 2019-03-31 18:17:43 PDT
Created attachment 366380 [details]
Patch
Comment 6 EWS Watchlist 2019-03-31 19:20:11 PDT
Comment on attachment 366380 [details]
Patch

Attachment 366380 [details] did not pass mac-ews (mac):
Output: https://webkit-queues.webkit.org/results/11723836

New failing tests:
fast/css/parsing-css-attribute-case-insensitive-value-3.html
imported/w3c/web-platform-tests/dom/nodes/Element-matches.html
imported/w3c/web-platform-tests/dom/nodes/Element-webkitMatchesSelector.html
imported/w3c/web-platform-tests/css/selectors/missing-right-token.html
fast/selectors/invalid-functional-pseudo-class.html
Comment 7 EWS Watchlist 2019-03-31 19:20:13 PDT
Created attachment 366381 [details]
Archive of layout-test-results from ews102 for mac-highsierra

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews102  Port: mac-highsierra  Platform: Mac OS X 10.13.6
Comment 8 EWS Watchlist 2019-03-31 19:34:50 PDT
Comment on attachment 366380 [details]
Patch

Attachment 366380 [details] did not pass mac-wk2-ews (mac-wk2):
Output: https://webkit-queues.webkit.org/results/11723876

New failing tests:
fast/selectors/invalid-functional-pseudo-class.html
imported/w3c/web-platform-tests/dom/nodes/ParentNode-querySelector-All-xht.xht
imported/w3c/web-platform-tests/dom/nodes/ParentNode-querySelector-All.html
imported/w3c/web-platform-tests/css/selectors/missing-right-token.html
fast/css/parsing-css-attribute-case-insensitive-value-3.html
imported/w3c/web-platform-tests/dom/nodes/Element-matches.html
imported/w3c/web-platform-tests/dom/nodes/Element-webkitMatchesSelector.html
Comment 9 EWS Watchlist 2019-03-31 19:34:52 PDT
Created attachment 366382 [details]
Archive of layout-test-results from ews107 for mac-highsierra-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews107  Port: mac-highsierra-wk2  Platform: Mac OS X 10.13.6
Comment 10 EWS Watchlist 2019-03-31 20:08:39 PDT
Comment on attachment 366380 [details]
Patch

Attachment 366380 [details] did not pass win-ews (win):
Output: https://webkit-queues.webkit.org/results/11724014

New failing tests:
fast/css/parsing-css-attribute-case-insensitive-value-3.html
fast/selectors/invalid-functional-pseudo-class.html
Comment 11 EWS Watchlist 2019-03-31 20:08:51 PDT
Created attachment 366383 [details]
Archive of layout-test-results from ews201 for win-future

The attached test failures were seen while running run-webkit-tests on the win-ews.
Bot: ews201  Port: win-future  Platform: CYGWIN_NT-6.1-2.10.0-0.325-5-3-x86_64-64bit
Comment 12 EWS Watchlist 2019-03-31 21:33:49 PDT
Comment on attachment 366380 [details]
Patch

Attachment 366380 [details] did not pass mac-debug-ews (mac):
Output: https://webkit-queues.webkit.org/results/11724337

New failing tests:
fast/css/parsing-css-attribute-case-insensitive-value-3.html
imported/w3c/web-platform-tests/dom/nodes/Element-matches.html
imported/w3c/web-platform-tests/dom/nodes/Element-webkitMatchesSelector.html
imported/w3c/web-platform-tests/css/selectors/missing-right-token.html
fast/selectors/invalid-functional-pseudo-class.html
Comment 13 EWS Watchlist 2019-03-31 21:33:51 PDT
Created attachment 366385 [details]
Archive of layout-test-results from ews115 for mac-highsierra

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews115  Port: mac-highsierra  Platform: Mac OS X 10.13.6
Comment 14 EWS Watchlist 2019-03-31 23:19:39 PDT
Comment on attachment 366380 [details]
Patch

Attachment 366380 [details] did not pass ios-sim-ews (ios-simulator-wk2):
Output: https://webkit-queues.webkit.org/results/11724830

New failing tests:
fast/selectors/invalid-functional-pseudo-class.html
imported/w3c/web-platform-tests/dom/nodes/ParentNode-querySelector-All-xht.xht
imported/w3c/web-platform-tests/dom/nodes/ParentNode-querySelector-All.html
imported/w3c/web-platform-tests/css/selectors/missing-right-token.html
fast/css/parsing-css-attribute-case-insensitive-value-3.html
imported/w3c/web-platform-tests/dom/nodes/Element-matches.html
imported/w3c/web-platform-tests/dom/nodes/Element-webkitMatchesSelector.html
Comment 15 EWS Watchlist 2019-03-31 23:19:41 PDT
Created attachment 366388 [details]
Archive of layout-test-results from ews125 for ios-simulator-wk2

The attached test failures were seen while running run-webkit-tests on the ios-sim-ews.
Bot: ews125  Port: ios-simulator-wk2  Platform: Mac OS X 10.13.6
Comment 16 Emilio Cobos Álvarez (:emilio) 2019-04-01 02:19:53 PDT
Created attachment 366392 [details]
Patch
Comment 17 Antti Koivisto 2019-04-01 02:44:56 PDT
Comment on attachment 366392 [details]
Patch

r=me
Comment 18 WebKit Commit Bot 2019-04-01 05:50:50 PDT
Comment on attachment 366392 [details]
Patch

Clearing flags on attachment: 366392

Committed r243691: <https://trac.webkit.org/changeset/243691>
Comment 19 WebKit Commit Bot 2019-04-01 05:50:52 PDT
All reviewed patches have been landed.  Closing bug.
Comment 20 Radar WebKit Bug Importer 2019-04-01 05:51:25 PDT
<rdar://problem/49476626>