Fix double-escaped entities in renderAsPlaintext code spans#320336
Draft
roblourens wants to merge 1 commit into
Draft
Fix double-escaped entities in renderAsPlaintext code spans#320336roblourens wants to merge 1 commit into
roblourens wants to merge 1 commit into
Conversation
The plaintext markdown renderer's codespan handler called escape() on text that marked had already HTML-escaped during tokenization. The trailing unescape pass in renderAsPlaintext only reverses one level, so entities inside code spans leaked through double-escaped (e.g. & -> &, < -> <). Removing the redundant escape() makes code spans match code-block behavior. (Written by Copilot)
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes renderAsPlaintext producing double-escaped HTML entities inside Markdown inline code spans (`...`) by removing an extra escaping step in the plaintext renderer, aligning code span handling with marked’s own token escaping.
Changes:
- Stop re-escaping
markedcodespan token text increatePlainTextRendererto prevent double-escaped entities. - Add a regression test ensuring entities/HTML-like content in code spans renders as expected in plaintext output.
Show a summary per file
| File | Description |
|---|---|
| src/vs/base/browser/markdownRenderer.ts | Removes redundant escaping in the plaintext codespan renderer to avoid double-escaped entities. |
| src/vs/base/test/browser/markdownRenderer.test.ts | Adds a regression test covering plaintext rendering of code spans containing escapable characters/entities. |
Copilot's findings
- Files reviewed: 2/2 changed files
- Comments generated: 1
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.
For #303752
I think this is ok but please take a quick look @mjbvz
Problem
Text inside markdown code spans (e.g.
foo & bar) rendered throughrenderAsPlaintextcame out double-escaped —&appeared as&,</>as</>. This surfaced in the agent sessions list, where a local (VS Code harness) session's in-progress description is derived from a tool invocation message viagetInProgressSessionDescription→renderAsPlaintext.Root cause
In
createPlainTextRenderer, thecodespanhandler calledescape(text). But marked already HTML-escapes code span text during tokenization. The trailing unescape pass inrenderAsPlaintextonly reverses a single level, so the extraescape()left entities double-escaped. Code blocks were unaffected because marked passes their text raw (escaped exactly once).Run \tests & build``Run tests & buildRun tests & buildUse \``Use <form>Use <form>Fix
Remove the redundant
escape()from thecodespanplaintext renderer so it matches code-block behavior. Added a regression test.This is a shared low-level helper, so the fix corrects the same double-escaping for all
renderAsPlaintextcallers (hovers, pickers, etc.), not just the agent sessions list.(Written by Copilot)