Skip to content

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

Description

@HUAN2022A

Description

On Windows, a file: URI whose drive-letter colon is percent-encoded (C%3A) is converted into a path with a duplicated drive prefix. This causes MarkItDown.convert_uri() to fail before conversion.

The equivalent URI with an unescaped colon works correctly.

Reproduction

from markitdown import MarkItDown
from markitdown._uri_utils import file_uri_to_path

working_uri = file:///C:/Temp/example.md
encoded_uri = file:///C%3A/Temp/example.md

print(file_uri_to_path(working_uri))
print(file_uri_to_path(encoded_uri))

MarkItDown().convert_uri(encoded_uri)

With an existing C:\Temp\example.md, the output is:

(None, 'C:\\Temp\\example.md')
(None, 'C:\\C:\\Temp\\example.md')
OSError: [Errno 22] Invalid argument: 'C:\\C:\\Temp\\example.md'

Expected behavior

The percent-encoded and unescaped drive-letter URIs should resolve to the same local path:

C:\Temp\example.md

Environment

  • OS: Windows 11
  • Python: 3.12.12
  • MarkItDown: 0.1.6
  • Repository commit: e144e0a

Possible cause

file_uri_to_path() calls url2pathname(parsed.path) and then os.path.abspath(...). On Windows, %3A is not decoded into the drive separator before abspath runs, so the current drive is prepended to a path that still contains the encoded drive component.

I searched existing issues for C%3A, percent-encoded Windows file URIs, and file_uri_to_path with no matching report found.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions