-
Notifications
You must be signed in to change notification settings - Fork 384
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
Fix dispatch_key handling for NAME_VALUE_DISPATCH; add cdata validation #926
Conversation
…ata-multi-size=''] issue h/t @Gregable
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.
Thanks @westonruter, I added minor comments but this is good to go.
* @return true|WP_Error Validity. | ||
*/ | ||
private function validate_amp_keyframe( $style ) { | ||
if ( strlen( $style->textContent ) > 500000 ) { |
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.
Maybe better to store 500000 in constant.
* https://github.com/ampproject/amphtml/blob/eda1daa8c40f830207edc8d8088332b32a15c1a4/validator/validator.proto#L111-L120 | ||
*/ | ||
|
||
// Indicates that the attribute does not form a dispatch key. |
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.
Would be good to add valid PHPDoc with @SInCE tags for these constances.
@@ -88,6 +88,13 @@ public function collect_style_elements() { | |||
continue; | |||
} | |||
|
|||
if ( 'body' === $style_element->parentNode->nodeName && $style_element->hasAttribute( 'amp-keyframes' ) ) { | |||
$validity = $this->validate_amp_keyframe( $style_element ); |
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 guess this doesn't really have to be stored in a var and could part of the conditional statement above.
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.
The reason behind is is that in #912 we need to add reporting and $validity
is a WP_Error
instance, so we'd want to report it when this is merged into that PR.
Thanks, I'll address these in the next PR. |
This fixes the longstanding annoyance for when the spec was read, the one
value
had to be removed fordata-multi-size
or else unit tests would fail. It turns out to be due to thedispatch_key
not being supported. So this is now fixed and the list of tags and attributes can be re-generated at will.In addition to
dispatch_key
being included in the generated PHP file, so toocdata
is now included, with validation for blacklisted regex and amp-keyframes styles. This is needed for validating elements in thehead
. See #926.