From 29d4ff048348f4a6bde9e5e4af81bd9509b7ac91 Mon Sep 17 00:00:00 2001 From: ferkans-amir Date: Mon, 27 Jul 2026 22:01:58 +0200 Subject: [PATCH] fix(uri): unquote percent-encoded file URI paths in file_uri_to_path --- packages/markitdown/src/markitdown/_uri_utils.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/packages/markitdown/src/markitdown/_uri_utils.py b/packages/markitdown/src/markitdown/_uri_utils.py index 603da63e9..4f93bd9e1 100644 --- a/packages/markitdown/src/markitdown/_uri_utils.py +++ b/packages/markitdown/src/markitdown/_uri_utils.py @@ -2,7 +2,7 @@ import os from typing import Tuple, Dict from urllib.request import url2pathname -from urllib.parse import urlparse, unquote_to_bytes +from urllib.parse import urlparse, unquote_to_bytes, unquote def file_uri_to_path(file_uri: str) -> Tuple[str | None, str]: @@ -12,7 +12,8 @@ def file_uri_to_path(file_uri: str) -> Tuple[str | None, str]: raise ValueError(f"Not a file URL: {file_uri}") netloc = parsed.netloc if parsed.netloc else None - path = os.path.abspath(url2pathname(parsed.path)) + raw_path = unquote(parsed.path) if "%" in parsed.path else parsed.path + path = os.path.abspath(url2pathname(raw_path)) return netloc, path