fix(webdav): decode percent-encoded names in PROPFIND/SEARCH responses
`<d:href>` is required by RFC 3986 to be percent-encoded, so non-ASCII filenames (e.g. Chinese, Cyrillic) were leaking through `list_directory` and the SEARCH-based tools (`find_by_name`, `find_by_type`, `list_favorites`, `search_files`) as their URL-encoded form. Decode with the already-imported `urllib.parse.unquote` before exposing to callers. Fixes #776 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.7
parent
fcc8dab6f6
commit
928b973eb8
@@ -257,9 +257,11 @@ class WebDAVClient(BaseNextcloudClient):
|
||||
if href is None:
|
||||
continue
|
||||
|
||||
# Extract file/directory name from href
|
||||
# Extract file/directory name from href. <d:href> is required by
|
||||
# RFC 3986 to be percent-encoded, so non-ASCII names arrive
|
||||
# encoded — decode before exposing to callers (issue #776).
|
||||
href_text = href.text or ""
|
||||
name = href_text.rstrip("/").split("/")[-1]
|
||||
name = unquote(href_text.rstrip("/").split("/")[-1])
|
||||
if not name:
|
||||
continue
|
||||
|
||||
@@ -767,8 +769,10 @@ class WebDAVClient(BaseNextcloudClient):
|
||||
if href is None:
|
||||
continue
|
||||
|
||||
# Extract file/directory path from href
|
||||
href_text = href.text or ""
|
||||
# Extract file/directory path from href. <d:href> is required by
|
||||
# RFC 3986 to be percent-encoded, so non-ASCII paths arrive
|
||||
# encoded — decode before exposing to callers (issue #776).
|
||||
href_text = unquote(href.text or "")
|
||||
# Remove the /remote.php/dav/files/username/ prefix to get relative path
|
||||
path_parts = href_text.split("/files/")
|
||||
if len(path_parts) > 1:
|
||||
|
||||
Reference in New Issue
Block a user