-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add @-moz-document to the CSS at-rule allowlist #26406
Comments
It turns out that the newest version of the Twenty Nineteen theme in WordPress core now makes use of Perhaps AMP documents could allow the at-rule with no value supplied in the @-moz-document url-prefix() {
/* ... */
} This is apparently what Firefox parses, and it ignores the value provided in the As I understand, Firefox tried removing |
cc @ampproject/wg-caching |
Incidentally, |
If |
@dvoytenko @molnarg for thoughts on the css rule changes. |
I have some concerns. An AMP page can be opened from a direct origin or from a CDN. Either |
@dvoytenko The predominant usage is for This can be confirmed by looking at this Pen in Firefox: https://codepen.io/westonruter/pen/eYZGOLm?editors=1100 The usage of an empty
So an empty value is the only one that Firefox now recognizes, and it's the only one that AMP should allow to support Firefox-specific CSS hacks. Even if AMP allowed a non-empty Almost all usages of |
@westonruter Ok. This sounds a bit better, but still some risks to consider if this rule can be abused by overtargetting to FF and leaving some features incomplete in other browsers. Do you have an example of a bug that you're fixing in FF this way? |
@dvoytenko Yes, this Firefox hack is being used to fix a rendering issue for drop caps in the Twenty Nineteen theme (actively installed on 600K+ websites) in WordPress core. Notice the difference in the drop cap's margins in non-AMP (expected) and AMP (unexpected) where in the latter the See WP core commit and original WP core ticket (originally WordPress/twentynineteen#749) for more screenshots. |
@westonruter I see. This is certainly an annoying bug. Do you btw have a Firefox bug number? |
For unexpected margins being set on on Nevertheless, the issue is not limited to workarounds for @-moz-document url-prefix() {
.control-section.open .customize-control:last-child {
margin-bottom: 20px;
}
} @-moz-document url-prefix() {
.panel-row-style {
background-position: center !important;
}
} @-moz-document url-prefix() {
#option-tree-options-layouts-form .select-wrapper {
left: 250px;
}
} |
There appears to be some confusion here, I see plenty of issues around deprecating and removing this functionality... but it does appear to work still. https://bugzilla.mozilla.org/show_bug.cgi?id=1615623 My hunch is we should allow it, since it's an existing web compat issue. |
Should we then allowlist with only empty |
Yes, that would prevent it from being used in old Firefox installs for “exfiltration in CSS-injection attacks”. |
No concern from security PoV if we only allow empty value. |
Worth noting that the Validator doesn't currently have a mechanism to evaluate the Here are the options as I see them:
Thoughts from this group on the three options? |
I understand from Bug 1035091 that Mozilla removed support for
If not 1, then this is my preference. |
I'd prefer option 2 for completeness, and to eliminate confusion around the functionality. |
I'd prefer option 2 (or 3), just so that we don't depend on
These are both quite unlikely but also hard for us to notice. |
I found an alternate CSS hack for Firefox, to use So this issue is no longer a blocker for the AMP plugin. |
I'd like to revisit this and recommend option 1 from #26406 (comment). In particular, I recommend supporting To date, AMP validation doesn't validate this part of CSS with the exception of verifying it parses correctly. There are also rules for As far as I can tell, the only conditional group rule usable with Am I missing a specific concern? |
My main concern was that |
That usage hasn't been supported since Firefox 59 which was released almost 3 years ago. Firefox since has only supported |
Ok. I guess that makes our lives a bit easier? |
What kind of abuse do you have in mind? If a publisher wanted to intentionally produce different UIs on cache and origin, this is already quite possible. They could respond differently based on useragent for example, giving the cache an entirely different document than user requests. I suspect there are probably other ways to do this within a static AMP page too, either via amp javascript, mustache, or even something like a css rule that depends on an attribute the cache inserts into the html tag or something like that. |
I was thinking more about differences on different caches. But I see your point. We can relax in these circumstances. |
Fixed in #32133 |
A few WordPress themes I've been evaluating for AMP compatibility are making use of the experimental
@document
CSS at-rule (more specifically,@-moz-document
).Specifically, there are
69 instances275 instances I've found across ~4,000 themes.Every instance I've seen is used as a browser sniffing technique, for example:
Nevertheless, the MDN docs notes that this at-rule has been disabled now in stylesheets coming from webpages:
This being the case, perhaps this answers the question and support should not be added. Since AMP pages are never user or UA sheets, the rule would never be used by any browser yet.
The text was updated successfully, but these errors were encountered: