ampproject / amphtml

The AMP web component framework.
https://amp.dev
Apache License 2.0
14.89k stars 3.89k forks source link

AMP Cache: html parser bug w/ tagstack popping #35738

Open raindropsinfotech opened 3 years ago

raindropsinfotech commented 3 years ago

Please.. Please Help me.. we are in SERIOUS TROUBLE..

I followed the update cache and all other docs found on google but none of them help me wisely.. here is my problem, I had created AMP website for one of my client who is IVF doctor, and while searching in http://google.com like "dr malpani insemination kit" and clicking on search result we are getting blank page because of google amp cache, see google is creating url like this https://google.com/amp/s/www.drmalpani.com/knowledge-center/resources/tools/self-insemination-kit-india

image

the main amp url is this https://drmalpani.com/amp/knowledge-center/resources/tools/self-insemination-kit-india

I have no idea how to solve it.. am struggling since last 3 days so please help how we can remove blank page from google instead showing them right page

Please any one share the solution for this.. here is the view source from amp page

view-source:https://www.drmalpani.com/amp/knowledge-center/resources/tools/self-insemination-kit-india

also its not just happen with this single AMP page but almost all other AMP pages too.. so begging for your help.

samouri commented 3 years ago

@raindropsinfotech, sorry you've been running into trouble. I'm not an expert on our caching infrastructure, but one thing I know happens is that during ingestion we reparse and serialize the provided HTML. This ensures it renders identically across all browsers instead of allowing inconsistent error handling to take place. What you are seeing here is exactly that: inconsistent error handling flows. The whole strategy requires that the provided document is reasonably sound.

If you look at the AMP Cache version of the document, you'll see that essentially the entire page seems to live in the <amp-sidebar> component, which is why the page is blank (the sidebar is initially hidden).

If you look at the source document, the HTML provided for amp-sidebar is:

    <!-- Start Sidebar -->
    <amp-sidebar id="header-sidebar" class="ampstart-sidebar px3 md-hide lg-hide" layout="nodisplay" hidden>
      <div class="flex justify-start items-center ampstart-sidebar-header">
        <div role="button" on="tap:header-sidebar.toggle" tabindex="0" class="ampstart-navbar-trigger items-start">✕</div>
      </div>
      <nav class="ampstart-sidebar-nav ampstart-nav">
        <ul id="fresponsive" class="nav navbar-nav dropdown ml-auto"><li class="dropdown "><a href="https://www.drmalpani.com/about-us" class="dropdown-toggle" >About Us<i class="fa fa-angle-down" aria-hidden="true"></i></a><input type="checkbox" id="drop-AboutUs-1869347698" /> <label for="drop-AboutUs-1869347698" class="toggle"></label><ul class="dropdown-menu"><li class=" "><a href="https://www.drmalpani.com/about-us/profile" class="" data-toggle=''>Profile</a><li class=" "><a href="https://www.drmalpani.com/about-us/our-philosophy" class="" data-toggle=''>Our Philosophy</a><li class=" "><a href="https://www.drmalpani.com/about-us/awards-accolades" class="" data-toggle=''>Awards & Accolades</a><li class=" "><a href="https://www.drmalpani.com/about-us/hotels-near-the-clinic" class="" data-toggle=''>Hotels near the clinic</a><li class=" "><a href="https://www.drmalpani.com/about-us/press" class="" data-toggle=''>Press</a></ul></li><li class="dropdown "><a href="https://www.drmalpani.com/our-services" class="dropdown-toggle" >Treatments<i class="fa fa-angle-down" aria-hidden="true"></i></a><input type="checkbox" id="drop-Treatments-1375481304" /> <label for="drop-Treatments-1375481304" class="toggle"></label><ul class="dropdown-menu"><li class=" "><a href="https://www.drmalpani.com/our-services/overview" class="" data-toggle=''>Overview</a><li class=" "><a href="https://www.drmalpani.com/our-services/how-to-reach-us" class="" data-toggle=''>How to reach us</a><li class=" "><a href="https://www.drmalpani.com/our-services/ivf" class="" data-toggle=''>IVF</a><li class=" "><a href="https://www.drmalpani.com/our-services/icsi" class="" data-toggle=''>ICSI</a><li class=" "><a href="https://www.drmalpani.com/our-services/surrogacy" class="" data-toggle=''>Surrogacy</a><li class=" "><a href="https://www.drmalpani.com/our-services/egg-donation" class="" data-toggle=''>Egg Donation</a><li class=" "><a href="https://www.drmalpani.com/our-services/embryo-adoption" class="" data-toggle=''>Embryo Adoption</a></ul></li><li class="dropdown "><a href="https://www.drmalpani.com/knowledge-center" class="dropdown-toggle" >Knowledge Center<i class="fa fa-angle-down" aria-hidden="true"></i></a><input type="checkbox" id="drop-KnowledgeCenter-1448397514" /> <label for="drop-KnowledgeCenter-1448397514" class="toggle"></label><ul class="dropdown-menu"><li class=" "><a href="https://www.drmalpani.com/knowledge-center/the-infertile-man" class="" data-toggle=''>The Infertile Man</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/the-infertile-woman" class="" data-toggle=''>The Infertile Woman</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/coping-with-infertility" class="" data-toggle=''>Coping with Infertility</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/infertility-testing" class="" data-toggle=''>Infertility Testing</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/ivf" class="" data-toggle=''>IVF</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/failed-ivf" class="" data-toggle=''>Failed IVF</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/how-to-make-the-most-of-your-doctor" class="" data-toggle=''>How to Make the Most of your Doctor</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/the-infertility-quiz" class="" data-toggle=''>The Infertility Quiz</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/ivf-calender" class="" data-toggle=''>IVF Calendar</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/articles" class="" data-toggle=''>Articles</a><li class="dropdown-submenu "><a href="https://www.drmalpani.com/knowledge-center/resources" class="dropdown-toggle" >Resources<i class="fa fa-angle-right" aria-hidden="true"></i></a><input type="checkbox" id="drop-Resources-191868644" /> <label for="drop-Resources-191868644" class="toggle"></label><ul class="dropdown-menu"><li class=" "><a href="https://www.drmalpani.com/knowledge-center/resources/videos1" class="" data-toggle=''>Videos</a><li class="dropdown-submenu "><a href="https://www.drmalpani.com/knowledge-center/resources/books" class="dropdown-toggle" >Book<i class="fa fa-angle-right" aria-hidden="true"></i></a><ul class="dropdown-menu"><li class=" "><a href="https://www.drmalpani.com/knowledge-center/resources/books/how-to-have-a-baby" class="" data-toggle=''>How to Have a Baby</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/resources/books/ivf-comic-book" class="" data-toggle=''>IVF Comic book</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/resources/books/the-infertile-man-a-comic-book" class="" data-toggle=''>The Infertile Man - A Comic Book</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/resources/books/comicbook" class="" data-toggle=''>Free Comic Book on How to Have a Baby</a></ul><li class=" "><a href="https://www.drmalpani.com/knowledge-center/resources/shop-online" class="" data-toggle=''>Shop Online</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/resources/tools" class="" data-toggle=''>Tools</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/resources/faq" class="" data-toggle=''>FAQ</a></ul><li class=" "><a href="https://www.drmalpani.com/knowledge-center/ask-the-embryologist2" class="" data-toggle=''>Ask The Embryologist</a><li class=" "><a href="https://www.drmalpani.com/all-videos" class="" data-toggle=''>Watch Videos related to IVF</a><li class=" "><a href="https://www.drmalpani.com/knowledge-center/promotion" class="" data-toggle=''>Promotion</a></ul></li><li class=" "><a href="https://www.drmalpani.com/success-stories" class="" data-toggle=''>Success Stories</a></li><li class=" "><a href="https://www.drmalpani.com/free-second-opinion" class="" data-toggle=''>Free Email Opinion</a></li><li class=" "><a href="https://www.drmalpani.com/contact-us" class="" data-toggle=''>Contact Us</a></li>
      </nav>
    </amp-sidebar>

Throw that code into any formatter and it'll be obvious that many closing tags are missing. Specifically many many <li> tags are missing corresponding </li>s. Once these are fixed, the AMP Cache version should be fixed as well.


cc @ampproject/wg-caching

raindropsinfotech commented 3 years ago

@samouri thanks for the quick answer let me check this and get back to you

jridgewell commented 3 years ago

I can isolate (original) it down to the missing </ul> tags:

<amp-sidebar layout="nodisplay" hidden>
  <nav>
    <ul>
      <li><a href="https://www.drmalpani.com/contact-us">Contact Us</a></li>
  </nav>
</amp-sidebar>
<p>hello</p>

Our HTML parser isn't popping the <ul> from the tag stack when it encounters the </nav>. This is a bug in our parser.

A fix will take a few weeks to be deployed, but you can quickly fix on your end by inserting the appropriate closing tags.

/cc @ampproject/wg-caching

raindropsinfotech commented 3 years ago

@samouri LOVE YOU LOVE YOU LOVE YOU.. Millions of love from your Indian brother, you have solved my issue.. amazing.. amazing.. thanks.. TONS OF THANKS...

samouri commented 3 years ago

Glad we could help :)

Gregable commented 3 years ago

I'm going to leave this open for now and ask @amaltas or @honeybadgerdontcare to look into whether or not the cache is parsing this correctly. Since there is a successful workaround, this isn't high priority, but it is something I don't want to lose.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.