Skip to content

fix: truncate uppercase data image URIs - #2122

Merged
afourney merged 3 commits into
microsoft:mainfrom
pony-maggie:fix-uppercase-data-image-uri
Sep 2, 2026
Merged

fix: truncate uppercase data image URIs#2122
afourney merged 3 commits into
microsoft:mainfrom
pony-maggie:fix-uppercase-data-image-uri

Conversation

@pony-maggie

Copy link
Copy Markdown
Contributor

Summary

  • make image data URI truncation case-insensitive
  • keep preserving full data URIs when keep_data_uris=True
  • add regression coverage for uppercase DATA:image sources

Reproduction

Before this change, converting HTML with an image source like DATA:image/png;base64,AAAA emitted the full payload even though keep_data_uris defaults to False. Lowercase data:image sources were truncated, so uppercase schemes bypassed the intended behavior.

Tests

  • /tmp/markitdown-venv/bin/python -m pytest packages/markitdown/tests/test_module_misc.py::test_uppercase_data_image_uri_is_truncated_by_default packages/markitdown/tests/test_module_misc.py::test_data_uris -q
  • /tmp/markitdown-venv/bin/python -m pytest packages/markitdown/tests/test_module_vectors.py::test_convert_keep_data_uris packages/markitdown/tests/test_module_vectors.py::test_convert_stream_keep_data_uris -q
  • git diff --check

@pony-maggie

Copy link
Copy Markdown
Contributor Author

@microsoft-github-policy-service agree

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Lowercasing the entire potentially large URI introduces avoidable time and memory overhead.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Makes data-URI image truncation case-insensitive while preserving keep_data_uris=True.

Changes:

  • Detects uppercase and mixed-case data: schemes.
  • Adds regression coverage for truncation and preservation.
File summaries
File Description
_markdownify.py Adds case-insensitive scheme detection.
test_module_misc.py Tests uppercase data-image URIs.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 1
  • Review effort level: Balanced

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread packages/markitdown/src/markitdown/converters/_markdownify.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@afourney
afourney merged commit e57e332 into microsoft:main Sep 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants