Skip to content

Fix processing of element child sanitization loop when invalid elements are replaced with children#4512

Merged
westonruter merged 3 commits intodevelopfrom
fix/missing-amp-form-script
Apr 3, 2020
Merged

Fix processing of element child sanitization loop when invalid elements are replaced with children#4512
westonruter merged 3 commits intodevelopfrom
fix/missing-amp-form-script

Conversation

@westonruter
Copy link
Copy Markdown
Member

@westonruter westonruter commented Apr 2, 2020

Summary

Fixes #4511.

When an unrecognized element is encountered, it is replaced with its children. This process wasn't accounted for when looping over the children of an element to sanitize. This PR ensures that when a child element is removed, the next loop iteration will pick up with the first valid descendant node that was in the now-removed child.

Checklist

  • My pull request is addressing an open issue (please create one otherwise).
  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@googlebot googlebot added the cla: yes Signed the Google CLA label Apr 2, 2020
@westonruter westonruter added this to the v1.5.2 milestone Apr 2, 2020
@westonruter westonruter changed the title [Tentative] Ensure AMP script components are added when parent is invalid Fix processing of element child sanitization loop when invalid elements are replaced with children Apr 2, 2020
@westonruter westonruter marked this pull request as ready for review April 2, 2020 18:24
@westonruter westonruter requested a review from schlessera April 2, 2020 18:24
@westonruter westonruter merged commit 4193dbc into develop Apr 3, 2020
@westonruter westonruter deleted the fix/missing-amp-form-script branch April 3, 2020 07:29
westonruter added a commit that referenced this pull request Apr 3, 2020
…ts are replaced with children (#4512)

* Add failing test showing missing amp-form component script

* Fix sanitization loop when invalid node is replaced with children

* Add additional test case for gathering script from invalid parent
westonruter added a commit that referenced this pull request Apr 3, 2020
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cla: yes Signed the Google CLA

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Required component for amp-form not detected when invalid <amp-form> is removed from wrapped <form> element

3 participants