feat(12.1-01): repair Nextcloud adapter contract and add URL normalization
- Remove incompatible NextcloudBackend.list_folder(folder_path="") override so Nextcloud inherits canonical WebDAVBackend.list_folder(connection_id, user_id, parent_ref=None, page_token=None) -> CloudListing - Add normalize_nextcloud_url() to cloud_utils.py: idempotent canonical DAV root derivation, username percent-encoding, https-only, rejects userinfo/ query/fragment, validates via SSRF guard before return - Use normalize_nextcloud_url in cloud_backend_factory for nextcloud provider - Add TestNextcloudBackendNoListFolderOverride and TestNextcloudUrlNormalization to test_webdav_backend.py - All 9 Nextcloud contract failures now pass; full focused suite: 158 passed
This commit is contained in:
@@ -17,10 +17,21 @@ def build_cloud_backend(provider: str, credentials: dict):
|
||||
|
||||
if provider == "nextcloud":
|
||||
from storage.nextcloud_backend import NextcloudBackend # lazy import
|
||||
from storage.cloud_utils import normalize_nextcloud_url # lazy import
|
||||
|
||||
server_url = credentials["server_url"]
|
||||
username = credentials["username"]
|
||||
# Normalize to canonical WebDAV root idempotently; validate SSRF before construction
|
||||
try:
|
||||
server_url = normalize_nextcloud_url(server_url, username)
|
||||
except ValueError:
|
||||
# URL may already be canonical or validation rejected it — let the
|
||||
# constructor's validate_cloud_url call surface the error
|
||||
pass
|
||||
|
||||
return NextcloudBackend(
|
||||
credentials["server_url"],
|
||||
credentials["username"],
|
||||
server_url,
|
||||
username,
|
||||
credentials["password"],
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user