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:
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.
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 causesMarkItDown.convert_uri()to fail before conversion.The equivalent URI with an unescaped colon works correctly.
Reproduction
With an existing
C:\Temp\example.md, the output is:Expected behavior
The percent-encoded and unescaped drive-letter URIs should resolve to the same local path:
Environment
e144e0aPossible cause
file_uri_to_path()callsurl2pathname(parsed.path)and thenos.path.abspath(...). On Windows,%3Ais not decoded into the drive separator beforeabspathruns, 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, andfile_uri_to_pathwith no matching report found.