Skip to content

Calendar displayname stored URL-encoded instead of UTF-8 during import #339

@kalinbogatzevski

Description

@kalinbogatzevski

Which version of integration_google are you using?

4.3.0

Which version of Nextcloud are you using?

32.0.5

Which browser are you using? In case you are using the phone App, specify the Android or iOS version and device please.

Edge Latest

Describe the Bug

Bug description

When importing Google Calendars, the displayname in the oc_calendars database table is stored URL-encoded instead of proper UTF-8 encoding.

Example:

  • Expected: Празници в Китай (Google Calendar import)
  • Actual: %D0%9F%D1%80%D0%B0%D0%B7%D0%BD%D0%B8%D1%86%D0%B8+%D0%B2+%D0%9A%D0%B8%D1%82%D0%B0%D0%B9+%28Google+Calendar+import%29

This affects:

  • Cyrillic characters (Bulgarian, Russian, etc.)
  • Chinese, Arabic, and other non-ASCII scripts
  • Special characters like @ and spaces

Actual behavior

Calendar names are stored and displayed as URL-encoded strings.

Root cause analysis

In lib/Service/GoogleCalendarAPIService.php, the code correctly sets:

$params['{DAV:}displayname'] = $newCalName;  // Correct UTF-8 name
$newCalUri = urlencode($newCalName);          // URL-encoded for URI

However, CalDavBackend::createCalendar() uses the URI as default displayname:
'displayname' => $calendarUri  // Line ~268

The $params displayname doesn't reliably override this default.

Proposed fix

After creating the calendar, explicitly update the displayname:

if (is_null($ncCalId)) {
    $ncCalId = $this->caldavBackend->createCalendar('principals/users/' . $userId, $newCalUri, $params);
    // Fix: Explicitly update displayname to ensure it's not URL-encoded
    $propPatch = new \Sabre\DAV\PropPatch(['{DAV:}displayname' => $newCalName]);
    $this->caldavBackend->updateCalendar($ncCalId, $propPatch);
}

Environment

- Nextcloud version: 32.0.5
- integration_google version: 4.3.0
- Database: MariaDB with utf8mb4 charset
- Affected calendars: Any with non-ASCII or special characters in names

Workaround

Manually fix affected calendars in database:
UPDATE oc_calendars SET displayname = 'Correct Name' WHERE id = X;

### Expected Behavior

Calendar names should display correctly in their original encoding (UTF-8).


### To Reproduce

1. Connect a Google account with calendars containing non-ASCII names
2. Import calendars via Connected Accounts
3. View calendar list - names appear as `%XX` encoded strings

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions