Skip to content

Conversation

@torch2424
Copy link
Contributor

relates to #20225
relates to #21705

Pretty small change, but allows any class to be applied as an attribute mutation πŸ˜„

Example

Screen Shot 2019-06-04 at 6 30 23 PM

@torch2424 torch2424 requested a review from zhouyx June 4, 2019 16:31
'style': {
'*': new DefaultStyleAllowedAttributeMutationEntry(),
},
'class': {
Copy link
Contributor

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

Copy link
Contributor Author

@torch2424 torch2424 Jun 6, 2019

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.

@torch2424
Copy link
Contributor Author

@zhouyx Made requested changes, this is good to go! πŸ˜„

@torch2424
Copy link
Contributor Author

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 .i-amphtml-*.

But timezones so let's figure this out Monday πŸ˜„

@jridgewell
Copy link
Contributor

I think just blocking .i-amphtml- is enough.


// Don't allow the .i-amphtml class
// See `validator/validator-main.protoascii`
if (value.match(/(^|\\W)i-amphtml-/)) {
Copy link
Contributor

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

Copy link
Contributor Author

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 πŸ˜„

@torch2424 torch2424 merged commit 9034051 into ampproject:master Jun 27, 2019
@torch2424 torch2424 deleted the any-class-change branch June 27, 2019 01:39
Gregable pushed a commit that referenced this pull request Jul 2, 2019
* cl/255021843 Add a test file illustrating the issue in #18091

* cl/255463519 Revision bump for #22679

* cl/256058522 Revision bump for #23043

* cl/256067928 Revision bump for #23135

* cl/256199406 Revision bump for #23147
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants