microsoft / microsoft/markitdown
fix packages/markitdown/src/markitdown/_uri_utils.py
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 186k
- Forks
- 13.7k
- Avg merge
- 1d 4h
- Merged PRs (30d)
- 49
Description
- from urllib.parse import urlparse, unquote_to_bytes
- from urllib.parse import urlparse, unquote, unquote_to_bytes
- path = os.path.abspath(url2pathname(parsed.path))
- decoded_path = unquote(parsed.path)
- path = os.path.abspath(url2pathname(decoded_path))
Before the change, file_uri_to_path() passed parsed.path directly into url2pathname().
That usually works for simple ASCII file paths, but it breaks when the file URI contains percent-encoded non-ASCII characters such as Korean filenames. In our case, a URI like:
file:///D:/.../%EC%A0%9C20...hwpx
was not being decoded into the original Unicode path before conversion to a Windows filesystem path. As a result, the generated path became invalid and MCP failed to open the file.
The fix was to explicitly call unquote(parsed.path) first, so the percent-encoded URI path is restored to its real Unicode form before url2pathname() converts it into a local OS path.
In short:
- before: URI path stayed percent-encoded too long
- after: URI path is decoded first, then converted to a Windows path
That makes file: URIs with Unicode filenames work correctly in the MCP flow.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Open packages/markitdown/src/markitdown/_uri_utils.py and inspect file_uri_to_path(), starting with how parsed.path is passed to url2pathname(). Verify the change with a file URI containing a percent-encoded Unicode filename, and confirm the resulting Windows path lets the MCP flow open the file correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 1/5
- Estimated time
- 1-3 hours
- Activity status
- Quiet
- Clarity
- Clearly specified
- Newbie friendliness
- 82/100