Strip <script> from migrated CMS memo HTML - #2
Draft
posthog[bot] wants to merge 1 commit into
Draft
Conversation
Migrated Webflow memo bodies are stored as raw HTML and server-rendered verbatim through dangerouslySetInnerHTML, so any inline <script> in the content runs when the browser parses the page. Remove every script element at the HTML extraction boundary so CMS content can no longer run unchecked JavaScript. Generated-By: PostHog Desktop Task-Id: 3abd404c-aa20-468c-820f-f1e8c2851a63
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Can't find variable: CONFIG,Can't find variable: currentInset) that are one broken layout script degrading the footer. The class defect is bigger than the symptom: a memo body can run any JavaScript an editor pastes.dangerouslySetInnerHTMLatmemos/[slug]/page.tsx. Server-rendered<script>tags run on page parse, with no build-time checking.RichTextOrHtmlis the single choke point forbody,appendix,supporters, andtwitterEmbed, so this path is the only source of the offending script.Changes
stripScriptsand apply it at the HTML extraction boundary (extractHtmlFromLexical), so no CMS-supplied<script>reaches the rendered page.srcscripts, and orphan/self-closing script tags. Match is case-insensitive and spans newlines.Impact and caveats
widgets.jsscript is stripped); the<blockquote>fallback with a link to the tweet still renders. No crash.Note
Verified before shipping: this repo is the only
dangerouslySetInnerHTMLpath. Separately,wrangler.jsoncsetsPROJECT_DOMAINtowebsite.canadasbuilding.com— confirm this repo serveswww.buildcanada.combefore deploy; that config is out of scope for this fix.Agent context
Created with PostHog Desktop from this inbox report.