Skip to content

fix: encode spaces in caldav URLs - #1262

Open
papatenko-bot wants to merge 1 commit into
cbcoutinho:masterfrom
papatenko-bot:fix/url-encode-username-with-spaces
Open

fix: encode spaces in caldav URLs#1262
papatenko-bot wants to merge 1 commit into
cbcoutinho:masterfrom
papatenko-bot:fix/url-encode-username-with-spaces

Conversation

@papatenko-bot

@papatenko-bot papatenko-bot commented Aug 6, 2026

Copy link
Copy Markdown

Nextcloud hrefs embed the raw username. When the UID has a space, caldav's URL.join() keeps it and DAVObject.__init__ rejects the URL, breaking calendar reads and writes.

Changes

  • calendar.py: quote the username in the calendar-home URL and patch caldav URL.join() to percent-encode joined paths
  • tests: spaced usernames in the constructor, home-set discovery, and principal fallback paths

unquote() + quote() is idempotent, so already-encoded URLs are unaffected.

@CLAassistant

CLAassistant commented Aug 6, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@papatenko-bot
papatenko-bot force-pushed the fix/url-encode-username-with-spaces branch from 6e38ce7 to b952d85 Compare August 6, 2026 05:50
@papatenko-bot papatenko-bot changed the title fix: percent-encode usernames in DAV URL construction fix: encode spaces in caldav URLs Aug 6, 2026
@papatenko

Copy link
Copy Markdown

This primarily fixes the use case where user as a space within your username attempts to use the Calendar or other MCP tools.

Default User for example would cause the tool to not work before this change.

@cbcoutinho

Copy link
Copy Markdown
Owner

Hi @papatenko can you please add tests for this case? Spaces in usernames is a common source of strange bugs and is covered in other aspects of the codebase already

@papatenko-bot
papatenko-bot force-pushed the fix/url-encode-username-with-spaces branch 2 times, most recently from 1910f91 to 2c72042 Compare August 6, 2026 16:15
@papatenko-bot
papatenko-bot force-pushed the fix/url-encode-username-with-spaces branch from 2c72042 to 7873edf Compare August 6, 2026 16:28
@sonarqubecloud

sonarqubecloud Bot commented Aug 6, 2026

Copy link
Copy Markdown

@papatenko

Copy link
Copy Markdown

@cbcoutinho I added tests for it and narrowed down the scope of the bug fix to just CalDAV.

Calendar was the main issue to begin with; everything else works, except Contacts when using Claude Web. Here is the error I got from Claude:

list_addressbooks — server bug: crashes on an addressbook with a null display name (displayname Input should be a valid string). Contacts themselves are reachable if you know the URI slug.

Don't believe that is a result of the additions I made, but I could be wrong.

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.

4 participants