Skip to content

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

Merged
afourney merged 5 commits into
microsoft:mainfrom
tandede:agent/decode-windows-file-uri-drive
Sep 1, 2026
Merged

Fix percent-encoded Windows drive paths in file URIs#2315
afourney merged 5 commits into
microsoft:mainfrom
tandede:agent/decode-windows-file-uri-drive

Conversation

@tandede

Copy link
Copy Markdown
Contributor

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
Contributor 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
@tandede
Zhewen Tan (tandede) marked this pull request as ready for review August 19, 2026 11:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

The regression test does not emulate Windows-specific url2pathname behavior.

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

Pull request overview

Fixes percent-encoded Windows drive separators in file URIs before absolute-path resolution.

Changes:

  • Removes the erroneous leading separator from decoded Windows drive paths.
  • Adds a platform-independent regression test.
File summaries
File Description
_uri_utils.py Normalizes decoded Windows drive paths.
test_module_misc.py Tests encoded Windows drive 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/tests/test_module_misc.py
afourney and others added 2 commits September 1, 2026 16:57
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@afourney
afourney merged commit f1df5ac into microsoft:main Sep 1, 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.

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

3 participants