fix: extract HTMLBlocks before parsing in stripComments - #1506
Conversation
15f3ae6 to
f32201f
Compare
There was a problem hiding this comment.
Hmm why do we need to preserve comments in HTMLBlocks? I thought the point of this is to strip every comment, and also makes this code more complicated with these regexes.
If we do need to preserve them, then I don't think we need to extract the HTMLBlocks again? Since we already tokenise them, they should appear is 1 HTML node, so maybe we can just check if a visited node has <HTMLBlock> pattern, you can skip the comment stripping. Let me know if it makes sense.
There was a problem hiding this comment.
Right, comments get preserved in there & for magic blocks as well. I agree, I think stripping it in HTMLBlocks too sounds better, but would be good to confirm first.
There was a problem hiding this comment.
Yep for the stripComments pipeline we want to sanitize the entire page content of all comments, including HTMLBlocks.
|
Good use of the tokenizer! |
Remove the extract/restore logic that preserved HTML comments inside HTMLBlock content. Comments are now stripped uniformly everywhere, which is simpler and consistent with the security intent of CX-2511.
8da3726 to
c514139
Compare
c514139 to
8da3726
Compare
eaglethrost
left a comment
There was a problem hiding this comment.
Lgtm but good get a readme approval as well!
## Version 14.11.3 ### 🛠 Fixes & Updates * **mdxish:** escape stray `<` in table cells ([#1535](#1535)) ([807f61a](807f61a)) * esm statements in JSX component child text crash rendering ([#1541](#1541)) ([6347bab](6347bab)) * extract HTMLBlocks before parsing in stripComments ([#1506](#1506)) ([2c65c3f](2c65c3f)), closes [#1439](#1439) * release workflow breakage from npm engine drift ([#1542](#1542)) ([2288aa7](2288aa7)) <!--SKIP CI-->
This PR was released!🚀 Changes included in v14.11.3 |

🎯 What does this PR do?
stripCommentswithmdxish: truecrashes on pages with multiline HTMLBlock content. CommonMark'shtmlFlowintercepts unindented HTML tags inside the template literal, breaking the MDX expression parsing.Fix:
Add the HTMLBlock micromark tokenizer from PR #1439 to claim
<HTMLBlock>beforehtmlFlowcan. Same pattern asjsxTable.Files from #1439:
lib/micromark/html-block-component/syntax.tslib/micromark/html-block-component/index.tslib/mdast-util/html-block-component/index.ts🧪 QA tips
For testing ticket behavior:
.mdendpoint returns markdown (not a full HTML page)📸 Screenshot or Loom
Screen.Recording.2026-06-03.at.4.35.50.pm.mp4