Data URI fragments are decoded as payload, appending text or corrupting bytes

Aperta
#2,690 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

@sean0407 ci sta già lavorando.

Dal 10/10/2026.

  • #2691 di @sean0407 — aperta
  • #2726 di @OUAO-FRANK — aperta
  • #2775 di @huzaifaasim017 — aperta

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
30/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Ferma
Stack tecnologico
python
Ambito
backend

Direzione di ricerca

Start by reading parse_data_uri and the parser and public API regression tests mentioned in the issue. Check how raw fragments, %23, and ? are handled; done means both reported examples return the expected text while the escaped-hash and query controls continue to pass.

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

Descrizione

A raw #fragment becomes part of the converted content. With base64, it can silently add bytes.

from markitdown import MarkItDown

md = MarkItDown(enable_plugins=False)
print(repr(md.convert_uri('data:text/plain,Hello#section').text_content))
# Actual: 'Hello#section'; expected: 'Hello'

print(repr(md.convert_uri('data:text/plain;base64,SGVsbG8h#AAAA').text_content))
# Actual: 'Hello!\x00\x00\x00'; expected: 'Hello!'

Reproduced on main 4cc9fa17653d695d64fb9eee5b33d4de55ff84e8, macOS, Python 3.12.15. It also occurs on #2682, which fixes a different decoding problem.

parse_data_uri decodes everything after the comma, including the fragment. Strip the raw fragment before percent-decoding: %23 must still produce a literal #, and ? must remain in the payload. The WHATWG Fetch data URL processor excludes fragments; Node's fetch returns the expected text for both examples.

Parser and public API regression tests reproduced both failures. Escaped-hash and query controls passed. I searched existing issues and PRs and didn't find this failure covered.

Investigated with Hermes AI assistance.

Lingua principale
Python
Stelle
198k
Fork
15k
Merge medio
2h 16m
PR unite (30g)
9

Preparare l'ambiente

Apri in Codespaces

Avvia il container di sviluppo del progetto nel browser, con il tuo account GitHub.

  • Include un Dockerfile o un file Docker Compose
  • Nessun modello di pull request
  • Nessuna guida per i contributori

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 microsoft/markitdown

Tutte le issue di microsoft/markitdown

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.