Skip to content

fix: decode percent-encoded file URIs before path conversion#1745

Open
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix-uri-unquote
Open

fix: decode percent-encoded file URIs before path conversion#1745
Jah-yee wants to merge 1 commit intomicrosoft:mainfrom
Jah-yee:fix-uri-unquote

Conversation

@Jah-yee
Copy link
Copy Markdown

@Jah-yee Jah-yee commented Apr 13, 2026

Good day,

This PR fixes issue #1738.

Problem

Before this change, file_uri_to_path() passed parsed.path directly into url2pathname().
That works for simple ASCII file paths, but breaks when the file URI contains
percent-encoded non-ASCII characters such as Korean filenames.

For example, 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, causing the generated path to become invalid
and MCP failed to open the file.

Solution

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 Windows path

Changes

  • Added unquote to imports from urllib.parse
  • Decode URI path with unquote() before passing to url2pathname()

感谢你们的奉献,希望能提供帮助。如果我解决得有问题或有待商妥的地方,请在下面留言,我会来处理。

Warmly,
RoomWithOutRoof

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.

1 participant