Inline raw HTML is escaped after an unclosed `_` / `*` / `~` (regression in 18.2.1)
I maintainer di solito rispondono entro 4 giorni
Valutazione
- Difficoltà
- 2/5
- Tempo stimato
- 1-3 ore
- Idoneità per principianti
- 76/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Stack tecnologico
- markdown, typescript
Direzione di ricerca
Inizia in src/Lexer.ts, in Lexer.inlineTokens, e confronta i due inserimenti di token abbreviati con il modo in cui inlineText imposta il flag escaped nei blocchi non elaborati. Aggiungi test di regressione per gli esempi forniti di script e code, quindi esegui gli spec test pertinenti; il lavoro è completato quando il loro contenuto rimane non sottoposto a escape all’interno dei tag.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Marked version: 18.2.1 – 18.4.0 (also current master 002336a5). 18.2.0 is fine.
Describe the bug
Since 18.2.1, the content of inline raw HTML tags that marked keeps as-is (<script>, <code>, <pre>, <kbd>) gets HTML-escaped from the first _, * or ~ that has no closer. Everything before that character is left alone; everything after it is escaped.
We hit this with buttons that keep text in a <script type="template"> and copy it with innerText. Shell commands nearly always contain a _, so '1'" > was copied as '1'" >.
To Reproduce
marked.parse('Run <script>a_b = "1" > 2</script>')
marked.parse("Run <code>a_b '1' > x</code>")
18.2.0 (expected):
<p>Run <script>a_b = "1" > 2</script></p>
<p>Run <code>a_b '1' > x</code></p>
18.2.1 – 18.4.0 (actual):
<p>Run <script>a_b = "1" > 2</script></p>
<p>Run <code>a_b '1' > x</code></p>
Cause
git bisect between v18.2.0 and v18.2.1 points to 0b8b3b3 (#4196, "close residual O(n²) parse time on unmatched emphasis/strikethrough delimiter runs").
The new shortcut in Lexer.inlineTokens that consumes a closer-less */_/~ run pushes a text token with escaped: false, ignoring this.state.inRawBlock. inlineText sets escaped from inRawBlock, so before #4196 the whole span stayed raw. Now the rest of the raw text is merged into that new, unescaped token, and the renderer escapes it.
Possible fix
Use the raw-block state in both places the shortcut pushes a token (src/Lexer.ts):
- tokens.push({ type: 'text', raw, text: raw, escaped: false } as Tokens.Text);
+ tokens.push({ type: 'text', raw, text: raw, escaped: this.state.inRawBlock } as Tokens.Text);
With this on master, both examples above render as in 18.2.0. test:specs passes (2079/2079). test:unit has the same 5 failures as unmodified master in my environment, with nothing new. Happy to open a PR with a spec fixture if that helps.
Expected behavior
Text inside inline <script> / <code> / <pre> / <kbd> is output unchanged, as in 18.2.0
- Lingua principale
- TypeScript
- Stelle
- 37.3k
- Fork
- 3.9k
- Merge medio
- 5g 6h
- PR unite (30g)
- 62
Preparare l'ambiente
Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di markedjs/marked
-
Lazy continuation line inside a quoted list item is parsed as a nested listForse già presa @amstedy l’ha presa 1 giorno fa. ApertaL2 - annoying
Difficoltà 3/5 1-2 giorni Idoneità per principianti 45/100
markedjs/marked#4293 · 2 commenti ·
I maintainer di solito rispondono entro 4 giorni
-
Deeply nested emphasis is quadratic and overflows the stack in the lexerForse già presa @Pastalikek65 l’ha presa 5 giorni fa. Apertacategory: inline elements L2 - annoying
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
markedjs/marked#4286 · 1 commento ·
I maintainer di solito rispondono entro 4 giorni
-
proposal
Difficoltà 5/5 Più di una settimana Idoneità per principianti 22/100
markedjs/marked#4282 · 8 commenti ·
I maintainer di solito rispondono entro 4 giorni
-
Quadratic time in the inline `text` rule: its email look-ahead rereads the rest of the paragraphForse già presa @yxshee l’ha presa 10 giorni fa. ApertaL2 - annoying
Difficoltà 4/5 3-5 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 4 giorni
-
List item ends at a lazy line after a paragraph line indented 4+ columnsForse già presa @hakarrr l’ha presa 14 giorni fa. Aperta
Difficoltà 3/5 1-2 giorni Idoneità per principianti 35/100
I maintainer di solito rispondono entro 4 giorni
Tutte le issue di markedjs/marked
Issue simili
-
[Bug]: A Markdown link with both a :line suffix and a #L fragment opens a path containing ":line"Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
status:needs-triage type:bug workstream:refimpl
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
GenAI-Security-Project/agent-control-standard#764 ·
I maintainer di solito rispondono entro 1 giorno
-
good first issue
Difficoltà 2/5 1-3 ore Idoneità per principianti 85/100
TanbirRamim/vibereel#39 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
community first-timers-only good first issue hacktoberfest help wanted low hanging fruit up-for-grabs
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 72/100
lingdojo/kana-dojo#34988 · 1 commento · 5 reazioni ·
I maintainer di solito rispondono entro 1 giorno