Code spans that wrap onto the next line are no longer recognised (regression from the #702 fix)

Aperta
#756 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 3 giorni

@awais-ur-rehman ci sta già lavorando.

Dal 30/10/2026.

  • #757 di @awais-ur-rehman — aperta

Valutazione

Difficoltà
4/5
Tempo stimato
1-2 giorni
Idoneità per principianti
55/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Attiva
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start by reading _code_span_re and the #702 change that removed re.S, then trace the related safe mode handling described in the issue. Check how code spans with line endings are parsed and how safe_mode="escape" and safe_mode="replace" behave. Done means wrapped code spans are recognized while the #702 safety handling remains correct.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

Since 69635a9 (the fix for #702), a code span that wraps onto the next line is no longer recognised. This is common in hard-wrapped docs:

>>> markdown2.markdown("Call the `foo\nbar()` function.")
'<p>Call the `foo\nbar()` function.</p>\n'

Before that commit, the same input gave:

'<p>Call the <code>foo\nbar()</code> function.</p>\n'

The commit removed re.S from _code_span_re, so . in the pattern no longer matches the line ending. As far as I can tell this hasn't been released yet (it's after 2.5.5), so it might be worth sorting out before the next release.

Code spans can contain line endings in Markdown.pl and in CommonMark (spec, 6.1, where line endings are turned into spaces), so this looks unintended.

Simply putting re.S back doesn't seem right either. It doesn't bring back an executable XSS (the #702 example comes out escaped in safe_mode="escape"), but in safe_mode="replace" the tag is escaped instead of replaced. So the fix probably needs to happen together with the #702 handling. I didn't want to guess at the intended approach, so I'm opening this as an issue instead of a PR.

Lingua principale
Python
Stelle
2.8k
Fork
477
Merge medio
4g 6h
PR unite (30g)
12

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di trentm/python-markdown2

Tutte le issue di trentm/python-markdown2

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.