Skip to content
This repository has been archived by the owner on Oct 16, 2024. It is now read-only.

Escape pattern preview content #119

Merged
merged 2 commits into from
Mar 16, 2023
Merged

Escape pattern preview content #119

merged 2 commits into from
Mar 16, 2023

Conversation

mike-day
Copy link
Contributor

@mike-day mike-day commented Mar 16, 2023

This PR uses wp_kses_post to escape content used for pattern preview iFrames. This is just to help protect against malicious scripts that might be embedded in the pattern.


Before (<script> tags allowed):

Screenshot 2023-03-16 at 10 39 49 AM


After (<script> tags have been stripped):

Screenshot 2023-03-16 at 10 40 07 AM


How to test

  1. Checkout the branch
  2. Make sure previews load as expected
  3. If you are really enterprising, try to add an additional script — it should not execute

@mike-day mike-day changed the title Escape pattern previews Escape pattern preview content Mar 16, 2023
Copy link
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.

Good idea.

Sometimes post_content will have <script> tags, as even the Custom HTML block allows <script>.

If this ever becomes a problem, we can address it then. A user mentioned a problem from too much escaping in GCB.

But this is good now. It's always easier to lighten escaping that to tighten it.

@mike-day
Copy link
Contributor Author

Thanks @kienstra! Agreed that we can always lighten restrictions if it becomes an issue.

@mike-day mike-day merged commit bb047b5 into main Mar 16, 2023
@mike-day mike-day deleted the add/escape-pattern-previews branch March 16, 2023 16:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants