Skip to content

Fix percent-encoded Windows drive paths in file URIs - #2315

Draft
zhewen tan (tandede) wants to merge 1 commit into
microsoft:mainfrom
tandede:agent/decode-windows-file-uri-drive
Draft

Fix percent-encoded Windows drive paths in file URIs#2315
zhewen tan (tandede) wants to merge 1 commit into
microsoft:mainfrom
tandede:agent/decode-windows-file-uri-drive

Conversation

@tandede

Copy link
Copy Markdown

Summary

Fix percent-encoded Windows drive separators in file: URIs so paths such as file:///C%3A/Temp/example.md resolve to C:\Temp\example.md instead of retaining a leading separator that causes the current drive to be prepended again.

url2pathname() checks for a DOS drive before percent-decoding the path. When the colon is encoded, that check misses the drive and leaves a leading separator in the decoded Windows path. The conversion now removes that separator only when the decoded path has Windows drive syntax; POSIX and UNC paths are unchanged.

A platform-independent regression test emulates Windows path handling and verifies the encoded URI result.

Fixes #2208

Test plan

  • hatch test — 337 passed, 4 skipped
  • hatch run types:check src/markitdown/_uri_utils.py tests/test_module_misc.py
  • pre-commit run --all-files

@tandede

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@tandede
zhewen tan (tandede) force-pushed the agent/decode-windows-file-uri-drive branch from 5d9ad89 to 0cc54c4 Compare August 19, 2026 01:17
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.

Percent-encoded Windows drive colon in file URI produces a duplicated drive path

1 participant