Repository navigation
Fix data URI fragments being decoded as payload - #2775
Huzaifa Asim (huzaifaasim017) wants to merge 2 commits into
Conversation
|
@microsoft-github-policy-service agree |
…R watermark Ten new upstream PRs, none adopted. Four are real fixes (xlsx error values, ipynb string source, RSS 1.0, data URI fragment) whose defects reproduce on this fork but are outside the Windows/CJK exception class; six are noise or re-submissions of already-adopted microsoft#1913. Reasons and revisit triggers are in docs/DECISIONS.md. PR watermark 2765 -> 2775. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
PRABHU KIRAN VANDRANKI (VANDRANKI)
left a comment
There was a problem hiding this comment.
I ran this on Python 3.13.3 (Windows). PR head d392515 sits on current main 7482c09. The only caller of parse_data_uri in src is MarkItDown.convert_uri.
Both repros from #2690 are fixed. On main, convert_uri("data:text/plain,Hello#section") gives 'Hello#section' and the base64 one with #AAAA gives 'Hello!\x00\x00\x00'. On the PR they give 'Hello' and 'Hello!'. The controls Hello%23section (still Hello#section) and Hello?section (unchanged) behave as the issue asks.
Tests: tests/test_module_misc.py on the PR head is 173 passed, 1 skipped, 1 failed. The one failure is test_speech_transcription, and it fails the same way on main (169 passed, 1 skipped, 1 failed there). I copied the PR's test file onto main: the two fragment cases fail there and the escaped-hash and query cases pass, so the new test does separate fixed from broken.
Behavior changes to be aware of. I think both are correct under the WHATWG rule the issue cites, so I do not count them as blockers:
- A raw
#inside a text payload now cuts the payload. For exampledata:image/svg+xml;utf8,<svg fill='#fff'/>now decodes to<svg fill='(main kept the whole string). A caller has to write%23. A short note in the docstring would help. - A
#in the header part, likedata:text/plain;name=a#b,Hello, now raisesValueError: Malformed data URI, missing ',' separator. Main returnedHello.
Not run: I did not check the live HTML path where an <img src="data:..."> is converted, because parse_data_uri is not called there.
|
PRABHU KIRAN VANDRANKI (@VANDRANKI) Thanks for checking the repros and calling out the SVG/header edge cases. I pushed dc3aa0a with a Local verification: |
Summary
#, and?payloads through both the parser and public conversion API.Fixes #2690. Thanks to Bicheng (@BichengWang) for the detailed reproduction and expected behavior.
Verification
pytest -q packages/markitdown/tests/test_module_misc.py -k data_uri: 5 passed.test_module_misc.py: 162 passed, 11 skipped, 2 unrelated failures in this minimal environment (audio transcription and optional PPTX dependency).Developed with AI assistance; I reviewed the change and ran the tests above.