Bug 98303 - Parsing of media queries: 'all and(color)' should be invalid
Summary: Parsing of media queries: 'all and(color)' should be invalid
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: CSS (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL: http://dabblet.com/gist/3829879
Keywords:
Depends on:
Blocks:
 
Reported: 2012-10-03 14:36 PDT by Simon Sapin
Modified: 2022-07-13 11:10 PDT (History)
3 users (show)

See Also:


Attachments
Require some whitespace after 'and' in a media query. (863 bytes, patch)
2012-10-03 14:55 PDT, Simon Sapin
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Simon Sapin 2012-10-03 14:36:16 PDT
Example 20 of the Media Queries gives this invalid media query:

   @media all and(color) { … }

The lack of space in 'and(' makes it tokenize as a FUNCTION, and thus the query should parse as invalid.

http://www.w3.org/TR/css3-mediaqueries/#error-handling

A test case:

    /* The body should not be red */
    @media all and(color) { body { background: red } }

Or see it in action: http://dabblet.com/gist/3829879

I have this bug in Chromium 22 on Archlinux x86_64, but smfr just confirmed on IRC that it had been fixed in Safari 6.0.1 but regressed in the current trunk.
Comment 1 Simon Sapin 2012-10-03 14:43:01 PDT
If the User-Agent string is to be trusted, my Chromium build uses WebKit 537.4.
Comment 2 Simon Sapin 2012-10-03 14:55:06 PDT
Created attachment 166964 [details]
Require some whitespace after 'and' in a media query.

Sorry, untested patch. (I have yet to manage a build.) Other files might need to be changed, but this looks like the right area of the code.
Comment 3 Simon Sapin 2012-10-03 15:59:18 PDT
The patch is wrong, white space is not actually required. This is valid: "all and/*wooo!*/(color)".
http://lists.w3.org/Archives/Public/www-style/2012Oct/0099.html
Comment 4 karl 2014-06-29 19:28:24 PDT
David Baron in 
https://bugzilla.mozilla.org/show_bug.cgi?id=1031966#c7

> The CSSWG has had multiple extensive discussions 
> of this issue; in the last one we actually resolved 
> to require the whitespace (i.e., disallow "and/**/("):
> 
> http://lists.w3.org/Archives/Public/www-style/2013Jul/0082.html

And in 

> MQ4 says, in http://dev.w3.org/csswg/mediaqueries/#mq-syntax :
> 
> Whitespace must be present between a ')' character and 
> a not, and, or or keyword, and between a not, and, or 
> or keyword and a '(' character.

The parsing of "and(" fails in Opera (blink), IE11, Chrome, and Firefox.
Safari (to the best of my knowledge is the only one to parse it).
Comment 5 karl 2014-06-29 19:43:51 PDT
Related to this bug https://bugs.webkit.org/show_bug.cgi?id=45017
Comment 6 Brent Fulgham 2022-07-13 11:10:14 PDT
Safari, Chrome, and Firefox all agree on rendering for this test case. I don't believe there is any remaining compatibility issue.