-
Notifications
You must be signed in to change notification settings - Fork 3.9k
✨amp-experiment 1.0: Allowed all class changes #22679
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
Conversation
@@ -68,6 +69,9 @@ export const attributeMutationAllowList = { | |||
'style': { | |||
'*': new DefaultStyleAllowedAttributeMutationEntry(), | |||
}, | |||
'class': { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there're a bunch of internal class names that are only reserved for AMP only. For example everything starts with i-amphtml-*
. Could you please double check? Thank you
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh my you are completely correct, I was only thinking about security not validation 😂 Thank you!
Note to self: CSS Validation is in validator/validator-main.protoascii
. And we should try to piggy back off of an existing sanitizer in AMP.
@zhouyx Made requested changes, this is good to go! 😄 |
So, this PR will be merged once I get a response from the Runtime team ( @jridgewell ) on whether we need class restrictions on certain elements (especially AMP Components) other than But timezones so let's figure this out Monday 😄 |
I think just blocking |
|
||
// Don't allow the .i-amphtml class | ||
// See `validator/validator-main.protoascii` | ||
if (value.match(/(^|\\W)i-amphtml-/)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we declare a constant for this instead of inlining the regex
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Talked offline, since we are having a refactor, and the current code is like this. We went ahead and added some more comments, and will address this in the refactor 😄
relates to #20225
relates to #21705
Pretty small change, but allows any class to be applied as an attribute mutation 😄
Example