Amp-wp: Investigate validation errors that are not sanitized in WordPress.org themes

Created on 10 Jan 2020  路  7Comments  路  Source: ampproject/amp-wp

Bug Description

I'm doing an analysis of how the entire directory of themes on WordPress.org fair in terms of AMP-compatibility. For each theme (which doesn't go over the 50KB limit), I've obtained the validation results for the initial Hello World post, using the current 1.5-alpha state of the plugin.

The themes which the AMP plugin thinks is serving as valid AMP but actually is not, are:

Theme | Validation Error
------|-----------------
brovy | The mandatory tag 'meta name=viewport' is missing or incorrect. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml#required-markup)
catch-wedding | CSS syntax error in tag 'style amp-custom' - invalid declaration.
catch-wheels | CSS syntax error in tag 'style amp-custom' - invalid declaration.
curiosity-lite | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
curiosity-lite | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
curiosity-lite | CSS syntax error in tag 'style amp-custom' - invalid declaration.
foodoholic | CSS syntax error in tag 'style amp-custom' - invalid declaration.
hamza-lite | The mandatory tag 'meta name=viewport' is missing or incorrect. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml#required-markup)
intuitive | CSS syntax error in tag 'style amp-custom' - invalid declaration.
keep-calm-and-e-comm | The mandatory tag 'meta name=viewport' is missing or incorrect. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml#required-markup)
lakshmi-lite | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
lakshmi-lite | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
lakshmi-lite | CSS syntax error in tag 'style amp-custom' - invalid declaration.
namaste-lite | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
namaste-lite | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
namaste-lite | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
namaste-lite | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
namaste-lite | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
nullpoint | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
nullpoint | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
organic-lite | CSS syntax error in tag 'style amp-custom' - invalid declaration.
organic-lite | CSS syntax error in tag 'style amp-custom' - invalid declaration.
palette | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
palette | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
personal-trainer | CSS syntax error in tag 'style amp-custom' - invalid declaration.
postmag | The property 'width' in attribute 'content' in tag 'meta name=viewport' is set to ' device-width', which is invalid. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml#required-markup)
robot | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
robot | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
ultimate-showcase | The mandatory tag 'meta name=viewport' is missing or incorrect. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml#required-markup)
zincy-lite | The mandatory tag 'meta name=viewport' is missing or incorrect. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml#required-markup)

The frequency is as follows:

Count | Error
-----: | ------
15 | CSS syntax error in tag 'style amp-custom' - end of stylesheet encountered in prelude of a qualified rule.
9 | CSS syntax error in tag 'style amp-custom' - invalid declaration.
5 | The mandatory tag 'meta name=viewport' is missing or incorrect. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml#required-markup)
1 | The property 'width' in attribute 'content' in tag 'meta name=viewport' is set to ' device-width', which is invalid. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml#required-markup)

The themes are:

  1. brovy
  2. catch-wedding
  3. catch-wheels
  4. curiosity-lite
  5. foodoholic
  6. hamza-lite
  7. intuitive
  8. keep-calm-and-e-comm
  9. lakshmi-lite
  10. namaste-lite
  11. nullpoint
  12. organic-lite
  13. palette
  14. personal-trainer
  15. postmag
  16. robot
  17. ultimate-showcase
  18. zincy-lite

Expected Behaviour

When the AMP plugin intends to serve a valid AMP page, no validation errors should be encountered by the AMP validator.

Steps to reproduce

  1. Enable AMP Standard template mode.
  2. Activate one of the above themes.
  3. Navigate to the Hello World post.
  4. Look for validation errors reported by the AMP validator.

Screenshots

Additional context

  • WordPress version:
  • Plugin version:
  • Gutenberg plugin version (if applicable):
  • AMP plugin template mode:
  • PHP version:
  • OS:
  • Browser: [e.g. chrome, safari]
  • Device: [e.g. iPhone6]

_Do not alter or remove anything below. The following sections will be managed by moderators only._

Acceptance criteria

Issues #4070, #4113, #4179 and #4197 were created to resolve the errors above and they should be resolved before this issue can be closed.

Implementation brief

QA testing instructions

Demo

Changelog entry

Bug Validation

All 7 comments

For the themes that have excessive CSS, there is just one that has unexpected validation errors: corpoz. There appears to be a problem with the output buffering because the first content is <title> followed later by <!DOCTYPE html>.

CSS syntax error in tag 'style amp-custom' - invalid declaration.

These seem to all be instances of #4113, except for curiosity-lite and lakshmi-lite.

In organic-lite it is due to properties like 4z-index:1;.

brovy The mandatory tag 'meta name=viewport' is missing or incorrect. (see https://amp.dev/documentation/guides-and-tutorials/learn/spec/amphtml#required-markup)

I suspect this one will be resolved by #4070. The meta viewport added by the theme is:

<meta name="viewport" content="width=device-width, initial-scale=1, user-scalabe=no">

So the invalid properties are causing the meta tag to be removed.

An overview of the work being done to resolve the validation errors reported above:

Theme | Reported Issue
---|---
brovy | #4070
catch-wedding | #4113
catch-wheels | #4113
curiosity-lite | #4197
foodoholic | #4113
hamza-lite | #4070
intuitive | #4113
keep-calm-and-e-comm | #4070
lakshmi-lite | #4197
namaste-lite | #4197
nullpoint | #4197
organic-lite | #4113
palette | #4197
personal-trainer | #4113
postmag | #4070, #4179 and #4197
robot | #4197
ultimate-showcase | #4070
zincy-lite | #4070

Now that the sub-issues (#4070, #4113, #4179, #4197) created from this discovery are resolved, I'll review the themes in question once more to ensure the reported validation errors for each no longer occurs.

All reported validation errors for each theme are fixed :tada:.

For the themes that have excessive CSS, there is just one that has unexpected validation errors: corpoz. There appears to be a problem with the output buffering because the first content is followed later by <!DOCTYPE html>.</p> </blockquote> <p>Ah I missed that one. I'll open a separate issue for that, but this issue can be closed since the validation errors in the description are resolved.</p> </div> <div class="card-footer"> <div class="row"> <div class="col"> <img src="https://avatars0.githubusercontent.com/u/16200219?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="pierlon picture"> <strong>pierlon</strong> <span class="text-muted ml-1">on 20 Feb 2020</span> </div> <div class="col text-right"> </div> </div> </div> </div> <div class="card card-custom mb-4"> <div class="card-body pt-3 pb-3 markdown"> <blockquote> <p>Ah I missed that one. I'll open a separate issue for that, but this issue can be closed since the validation errors in the description are resolved.</p> </blockquote> <p>Sounds good. </p> </div> <div class="card-footer"> <div class="row"> <div class="col"> <img src="https://avatars2.githubusercontent.com/u/134745?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="westonruter picture"> <strong>westonruter</strong> <span class="text-muted ml-1">on 20 Feb 2020</span> </div> <div class="col text-right"> </div> </div> </div> </div> </div> <div class="col-12"> <div class="card card-custom mb-4"> <div class="card-body pt-3 pb-3 markdown text-center helpful"> <div class="title">Was this page helpful?</div> <div class="mt-1" onMouseLeave="rating(548291593, 0);"> <i class="fas fa-star inactive" id="star-1" onMouseOver="rating(548291593, 1);" onclick="rate(548291593, 1);"></i> <i class="fas fa-star inactive" id="star-2" onMouseOver="rating(548291593, 2);" onclick="rate(548291593, 2);"></i> <i class="fas fa-star inactive" id="star-3" onMouseOver="rating(548291593, 3);" onclick="rate(548291593, 3);"></i> <i class="fas fa-star inactive" id="star-4" onMouseOver="rating(548291593, 4);" onclick="rate(548291593, 4);"></i> <i class="fas fa-star inactive" id="star-5" onMouseOver="rating(548291593, 5);" onclick="rate(548291593, 5);"></i> </div> <div class="description text-small"><span id="rating-val">0</span> / 5 - <span id="rating-count">0</span> ratings</div> </div> </div> <div class="mb-4"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3835332123789605" data-ad-slot="3452512275" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> </div> <div class="col-12 col-lg-4"> <div id="ph-above-related"></div> <div class="card card-custom issue-box"> <div class="card-body pt-3 pb-5"> <h2 class="mb-4">Related issues</h2> <div> <strong> <a href="/amp-wp/446711455/text-font-size-is-sometimes-incorrect">Text font size is sometimes incorrect</a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars1.githubusercontent.com/u/3294597?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="miina picture"> <strong class="pr-1" dir="ltr">miina</strong>  路  <span class="px-1" dir="ltr">5</span><span>Comments</span> </div> <hr /> <div> <strong> <a href="/amp-wp/462683479/amp-soundcloud-playlist">amp soundcloud playlist</a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars0.githubusercontent.com/u/24996403?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="maciejmackowiak picture"> <strong class="pr-1" dir="ltr">maciejmackowiak</strong>  路  <span class="px-1" dir="ltr">5</span><span>Comments</span> </div> <hr /> <div> <strong> <a href="/amp-wp/499421410/adding-continuous-performance-testing-with-blackfire">Adding continuous performance testing with Blackfire</a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars1.githubusercontent.com/u/83631?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="schlessera picture"> <strong class="pr-1" dir="ltr">schlessera</strong>  路  <span class="px-1" dir="ltr">5</span><span>Comments</span> </div> <hr /> <div> <strong> <a href="/amp-wp/489780143/hook-for-remove-amp-stories-feed-from-header">Hook for remove AMP Stories feed from Header</a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars0.githubusercontent.com/u/257004?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="luizeof picture"> <strong class="pr-1" dir="ltr">luizeof</strong>  路  <span class="px-1" dir="ltr">4</span><span>Comments</span> </div> <hr /> <div> <strong> <a href="/amp-wp/435642032/amp-stories-setting-colors-for-the-quote-block-doesn-t-work">[AMP Stories] Setting colors for the quote block doesn't work</a> </strong> </div> <div class="text-muted text-small mt-2"> <img src="https://avatars1.githubusercontent.com/u/3294597?v=4&s=40" style="width:20px; height:20px;" class="mr-2 rounded float-left" alt="miina picture"> <strong class="pr-1" dir="ltr">miina</strong>  路  <span class="px-1" dir="ltr">5</span><span>Comments</span> </div> </div> </div> <div class="sticky-top pt-4"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3835332123789605" data-ad-slot="3919948963" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> <div id="ph-below-related-2" class="mt-4"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3835332123789605" data-ad-slot="3919948963" data-ad-format="auto" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> </div> <div class="col-12 col-lg-4"> </div> </div> <div class="skyscraper-container"> <ins class="adsbygoogle" style="display:block" data-ad-client="ca-pub-3835332123789605" data-ad-slot="7879185320" data-ad-format="vertical" data-full-width-responsive="true"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script> </div> </div> <div class="mt-5 spacer"></div> <footer class="mt-5 pb-2 py-4 text-center mt-auto"> <div class="container"> <a class="navbar-brand logo mr-5" href="/"> <img src="/assets/img/logo.svg" width="40" height="40" alt="bleepingcoder logo"> bleeping<strong>coder</strong> </a> <div class="mt-4"> bleepingcoder.com uses publicly licensed GitHub information to provide developers around the world with solutions to their problems. We are not affiliated with GitHub, Inc. or with any developers who use GitHub for their projects. We do not host any of the videos or images on our servers. All rights belong to their respective owners. </div> <div> Source for this page: <a href="https://www.github.com/ampproject/amp-wp/issues/4060" rel="nofollow noreferrer" target="_blank">Source</a> </div> </div> <hr class="mb-5 mt-5"> <div class="container"> <div class="row"> <div class="col-sm-4 col-lg mb-sm-0 mb-5"> <strong>Popular programming languages</strong> <ul class="list-unstyled mb-0 mt-2"> <li class="mb-2"> <a href="/python" dir="ltr">Python</a> </li> <li class="mb-2"> <a href="/javascript" dir="ltr">JavaScript</a> </li> <li class="mb-2"> <a href="/typescript" dir="ltr">TypeScript</a> </li> <li class="mb-2"> <a href="/cpp" dir="ltr">C++</a> </li> <li class="mb-2"> <a href="/csharp" dir="ltr">C#</a> </li> </ul> </div> <div class="col-sm-4 col-lg mb-sm-0 mb-5"> <strong>Popular GitHub projects</strong> <ul class="list-unstyled mb-0 mt-2"> <li class="mb-2"> <a href="/microsoft/vscode" dir="ltr">vscode</a> </li> <li class="mb-2"> <a href="/numpy/numpy" dir="ltr">numpy</a> </li> <li class="mb-2"> <a href="/ant-design/ant-design" dir="ltr">ant-design</a> </li> <li class="mb-2"> <a href="/mui-org/material-ui" dir="ltr">material-ui</a> </li> <li class="mb-2"> <a href="/vercel/next-js" dir="ltr">next.js</a> </li> </ul> </div> <div class="col-sm-4 col-lg mb-0"> <strong>More GitHub projects</strong> <ul class="list-unstyled mb-0 mt-2"> <li class="mb-2"> <a href="/rust-lang/rust" dir="ltr">rust</a> </li> <li class="mb-2"> <a href="/moment/moment" dir="ltr">moment</a> </li> <li class="mb-2"> <a href="/yarnpkg/yarn" dir="ltr">yarn</a> </li> <li class="mb-2"> <a href="/mozilla/pdf-js" dir="ltr">pdf.js</a> </li> <li class="mb-2"> <a href="/JuliaLang/julia" dir="ltr">julia</a> </li> </ul> </div> </div> </div> <hr class="mb-5 mt-5"> <div class="container text-muted"> 漏 2026 bleepingcoder.com - <a href="/bleeps" rel="nofollow">Contact</a><br /> By using our site, you acknowledge that you have read and understand our <a href="/cookies" rel="nofollow">Cookie Policy</a> and <a href="/privacy" rel="nofollow">Privacy Policy</a>. </div> </footer> <script src="https://code.jquery.com/jquery-3.5.1.slim.min.js" integrity="sha256-4+XzXVhsDmqanXGHaHvgh1gMQKX40OUvDEBTu8JcmNs=" crossorigin="anonymous"></script> <script async src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> <script src="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/js/bootstrap.min.js" integrity="sha384-wfSDF2E50Y2D1uUdj0O3uMBJnjuUD4Ih7YwaYd1iqfktj0Uod8GCExl3Og8ifwB6" crossorigin="anonymous"></script> <!--<script defer type="text/javascript" src="//s7.addthis.com/js/300/addthis_widget.js#pubid=ra-5fb2db66acbd74b2"></script>--> <script type="text/javascript" src="/assets/js/main.js"></script> <script src="https://cdn.jsdelivr.net/gh/google/code-prettify@master/loader/run_prettify.js"></script></body> </html>