Skip to content

fix packages/markitdown/src/markitdown/_uri_utils.py #1738

@llA1ll

Description

@llA1ll
  • 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions