Open PeteKersker opened 8 months ago
Thanks for letting us know :+1:
Index: apps/dav/lib/CardDAV/AddressBookImpl.php
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
diff --git a/apps/dav/lib/CardDAV/AddressBookImpl.php b/apps/dav/lib/CardDAV/AddressBookImpl.php
--- a/apps/dav/lib/CardDAV/AddressBookImpl.php (revision f49cff2f5af060963e6d5980d73f91a51562fa44)
+++ b/apps/dav/lib/CardDAV/AddressBookImpl.php (date 1701895491151)
@@ -274,13 +274,14 @@
foreach ($vCard->children() as $property) {
if ($property->name === 'PHOTO' && in_array($property->getValueType(), ['BINARY', 'URI'])) {
+ [$userBackend, $userId] = explode(':', $uri, 2);
$url = $this->urlGenerator->getAbsoluteURL(
$this->urlGenerator->linkTo('', 'remote.php') . '/dav/');
$url .= implode('/', [
'addressbooks',
substr($this->addressBookInfo['principaluri'], 11), //cut off 'principals/'
$this->addressBookInfo['uri'],
- $uri
+ urlencode($userBackend) . ':' . $userId,
]) . '?photo';
$result['PHOTO'] = 'VALUE=uri:' . $url;
The above patch may fix it.
The current code does not consider that the user backend name could contain a backslash. That's usually not the case for the integrated backends.
user_external should implement the IUserBackend to signal a proper backend name.
Wow! Thank you for such a quick response!
Yes, it fixed the problem, but it was a breaking change. The avatars for my regular contacts ended up with a malformed url (an extra ':').
Since you pointed me to the right place, I fiddled with the code and was able to get everything to work by implementing your suggestion for the user_external code, only in this section instead.
Here's what worked:
Replace $uri With urlencode($uri) No other changes
I'm new to all this, so what should I do to have this change considered for a future revision?
Update: Nextcloud 28
I upgraded to 28.0.3 and the contact photos now all come back as a circle with a ? in the middle. No url is returning at all. The patch above no longer works.
Reminder: I'm using User Authentication (IMAP) to authenticate. I'm willing to be a tester for my environment if that helps.
Nextcloud 28.0.5 continues with the same pattern I mentioned in March. No version of the patch discussed above helps.
Please let me know if there is any way I can help.
⚠️ This issue respects the following points: ⚠️
Bug description
When searching for a system address book user using the contact search button, the user's image avatar url needs to be escaped when using UserExternal_IMAP authentication.
This is what the system generates, which does not work: https://my.nextcloud.installation/remote.php/dav/addressbooks/system/system/system/OCA\UserExternal\IMAP:usercard.vcf?photo&size=32
Manually editing the url to escape each '\' to '%5c' does work: https://my.nextcloud.installation/remote.php/dav/addressbooks/system/system/system/OCA%5cUserExternal%5cIMAP:usercard.vcf?photo&size=32
Steps to reproduce
Expected behavior
The user's avatar image should be displayed. (Security is set correctly to allow it. The image displays correctly in the contacts app.)
Installation method
Community Manual installation with Archive
Nextcloud Server version
27
Operating system
Debian/Ubuntu
PHP engine version
PHP 8.2
Web server
None
Database engine version
MariaDB
Is this bug present after an update or on a fresh install?
Upgraded to a MAJOR version (ex. 22 to 23)
Are you using the Nextcloud Server Encryption module?
Encryption is Disabled
What user-backends are you using?
Configuration report
List of activated Apps
Nextcloud Signing status
Nextcloud Logs
Additional info
The issue is the same in Brave, Chrome, and Firefox Escaping the '\' in the inspector/debugger displays the image correctly.