Only move meta tags to the head when required and add processing for meta[http-equiv]#4505
Conversation
| $meta_element->parentNode->removeChild( $meta_element ); | ||
| } | ||
|
|
||
| continue; |
| */ | ||
| if ( | ||
| $meta_element->hasAttribute( 'name' ) && | ||
| preg_match( '/(^|\\s)(amp-.*|amp4ads-.*|apple-itunes-app|content-disposition|revisit-after|viewport)(\\s|$)/', $meta_element->getAttribute( 'name' ) ) |
There was a problem hiding this comment.
It makes me nervous to hard-code this here. It seems better to grab it from the spec.
|
@pierlon Please review my additions. |
pierlon
left a comment
There was a problem hiding this comment.
Thanks @westonruter, fetching the deny pattern from the spec makes things much more robust 👍 .
| * @return string Deny pattern. | ||
| */ | ||
| private function get_body_meta_tag_name_attribute_deny_pattern() { | ||
| static $pattern = null; |
There was a problem hiding this comment.
My initial method of directly supplying the pattern was indeed brittle in retrospect. Getting the pattern from the spec and making it static is much more robust.
| $amp_boilerplate = amp_get_boilerplate_code(); | ||
|
|
||
| return [ | ||
| $meta_charset = '<meta charset="utf-8">'; |
There was a problem hiding this comment.
These tests here are much more extensive than what I had before and covers the happy path of execution, along with potential mishaps that may occur 👍.
|
Pre-release build for testing: amp.zip (1.5.2-alpha-20200402T153920Z-03af649a3) |
…meta[http-equiv] (#4505) * Do not process generic meta tags * Obtain non-body meta name attribute pattern from spec * Make use of BODY_ANCESTOR_META_TAG_SPEC_NAME constant * Test meta[schema] and meta[property] * Add recognition and repositioning of meta[http-equiv] elements * Add critical use_document_element=true arg for AMP_Tag_And_Attribute_Sanitizer * Add tests for the discrete spec'ed meta tags Co-authored-by: Weston Ruter <westonruter@google.com>
|
Fix verified by user: https://wordpress.org/support/topic/error-in-structured-data-4/page/2/#post-12619449 |
* tag '1.5.2': Bump 1.5.2 Bump version to 1.5.1-RC1 Cache response status and headers when fetching external stylesheets (#4509) Fix securing multi-line mustache templates (#4521) Add CSS monitoring time series to Site Health debugging info (#4519) Update hostname used for WordPress TV embeds to fix external HTTP requests (#4524) Fix processing of element child sanitization loop when invalid elements are replaced with children (#4512) Account for more YouTube URL formats (#4508) Update selected featured image ID on select (#4453) Raise default threshold for disabling CSS caching (#4513) Cast i-amphtml-intrinsic-sizer dimensions to integers (#4506) Only move meta tags to the head when required and add processing for meta[http-equiv] (#4505) Fix failing tests (#4507) Bump 1.5.2-alpha



Summary
Fixes #4502.
metatags to theheadwhen they are required to be moved; allow other tags to be in thebody(in particular HTML5 Microdata tags).meta[http-equiv]tags.metatags.Checklist