Skip to content

Fix from_public_link: subdirectory installs and port TypeError#293

Open
ismakov-dh wants to merge 1 commit intoowncloud:masterfrom
ismakov-dh:fix/from-public-link
Open

Fix from_public_link: subdirectory installs and port TypeError#293
ismakov-dh wants to merge 1 commit intoowncloud:masterfrom
ismakov-dh:fix/from-public-link

Conversation

@ismakov-dh
Copy link
Copy Markdown

Summary

from_public_link had two bugs:

  • Subdirectory installs broken: URLs like https://example.com/owncloud/s/TOKEN produced https://example.com as the base URL, losing the /owncloud webroot. All subsequent WebDAV calls then hit the wrong path.
  • Port handling crashes (runtime error in from_public_link when port is not 80  #290): public_link_components.port returns int, but was concatenated with ":" + (string), raising TypeError on any URL with a non-default port. Introduced in 299a72c when the f-string was replaced with string concatenation.

Fix

Extracts the webroot by stripping /index.php/s/TOKEN or /s/TOKEN from the URL path. Handles all real-world formats:

URL format Result
https://host/s/TOKEN https://host
https://host/index.php/s/TOKEN https://host
https://host/owncloud/s/TOKEN https://host/owncloud
https://host/owncloud/index.php/s/TOKEN https://host/owncloud
https://host:8443/owncloud/s/TOKEN https://host:8443/owncloud

Test plan

  • Added unit tests covering all URL formats above (11 tests, no live server needed)
  • Verify against a live ownCloud instance with subdirectory install
  • Verify against a live ownCloud instance with non-default port

🤖 Generated with Claude Code

from_public_link failed in two scenarios:
- Subdirectory installs (e.g. https://example.com/owncloud/s/TOKEN)
  produced https://example.com as the base URL, losing the /owncloud
  webroot. The WebDAV path then pointed to the wrong location.
- The port was concatenated as int instead of str (owncloud#290), raising
  TypeError on any URL with a non-default port.

Now correctly extracts the webroot by stripping /index.php/s/TOKEN or
/s/TOKEN from the path, handles both pretty and non-pretty URL formats,
and converts port to str before concatenation.

Adds unit tests covering: root/subpath installs, pretty/non-pretty URLs,
port handling, and folder_password passthrough.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant