Skip to content

Fix securing multi-line mustache templates#4521

Merged
westonruter merged 1 commit intodevelopfrom
fix/multiline-mustache-template-securing
Apr 3, 2020
Merged

Fix securing multi-line mustache templates#4521
westonruter merged 1 commit intodevelopfrom
fix/multiline-mustache-template-securing

Conversation

@westonruter
Copy link
Copy Markdown
Member

Summary

The regex missed the all-important flag s which resulted in . not matching newlines.

Fixes #4254
Fixes #4276

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).

@westonruter westonruter added the Bug Something isn't working label Apr 3, 2020
@westonruter westonruter added this to the v1.5.2 milestone Apr 3, 2020
@googlebot googlebot added the cla: yes Signed the Google CLA label Apr 3, 2020
Copy link
Copy Markdown
Member

@amedina amedina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small indeed. LGTM.

Copy link
Copy Markdown
Contributor

@kienstra kienstra left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Works well

Hi @westonruter,
This works, good catch.

With this in a Custom HTML block:

<script type="text/plain" template="amp-mustache">
{{#baz}  
<table>
  <tr>
    <div id="testing">This is in a Mustache template</div>
  </tr>
</table>
{{/baz}}		
</script>
<style>#testing { background: #000000 }</style>

The mustache template is no longer removed:

amp-not-removed

...and the CSS is not tree-shaken:

shaken-here

@westonruter westonruter force-pushed the fix/multiline-mustache-template-securing branch from 8fae6e7 to 82f8f93 Compare April 3, 2020 17:55
@westonruter westonruter merged commit e6739a0 into develop Apr 3, 2020
@westonruter westonruter deleted the fix/multiline-mustache-template-securing branch April 3, 2020 18:09
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
westonruter added a commit that referenced this pull request Apr 10, 2020
…aching-reenable-button

* 'develop' of github.com:ampproject/amp-wp:
  Restore unification of multi-page post content in Reader mode (#4547)
  Prevent styles from being removed when in Customizer preview with Standard mode (#4553)
  Omit Jetpack from being activated during PHPUnit test runs
  Use title case for Paired Browsing link in edit post screen (#4540)
  Ensure that validation query vars persist through redirects (#4544)
  Update dependency babel-jest to v25.2.6 (#4510)
  Update dependency css-loader to v3.5.0 (#4537)
  Update dependency autoprefixer to v9.7.6 (#4539)
  Add requirements to plugin file header (#4543)
  Force status code of validation responses to be 200 (#4533)
  Update optimizer test specs (#4527)
  Bump stable tag to 1.5.2
  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)
  Mock Imgur embed tests
  Mock Facebook embed tests
  Standardize file and class names for embed handlers
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working cla: yes Signed the Google CLA

Projects

None yet

4 participants