From d5654e817887d2c4c98dae286ba9b021ba9e06fe Mon Sep 17 00:00:00 2001 From: Ralf Becker Date: Mon, 11 Oct 2021 09:50:46 +0200 Subject: [PATCH] fix CardDAV error with DAVx5 caused by PHP 8.0 throwing an error instead ignoring it with a warning PHP 8.0 ValueError: mb_convert_encoding(): Argument #3 ($from_encoding) contains invalid encoding "tf-" current code expected Content-Type header to have charset enclosed in quotes, which it was not --- addressbook/inc/class.addressbook_groupdav.inc.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/addressbook/inc/class.addressbook_groupdav.inc.php b/addressbook/inc/class.addressbook_groupdav.inc.php index 56146fc509..95a7d5ad86 100644 --- a/addressbook/inc/class.addressbook_groupdav.inc.php +++ b/addressbook/inc/class.addressbook_groupdav.inc.php @@ -696,10 +696,16 @@ class addressbook_groupdav extends Api\CalDAV\Handler { trim($attribute); list($key, $value) = explode('=', $attribute); + // check if value is enclosed in quotes + if (in_array($value[0], ['"', "'"], true) && $value[0] === substr($value, -1)) + { + $value = substr($value,1,-1); + } switch (strtolower($key)) { case 'charset': - $charset = strtoupper(substr($value,1,-1)); + $charset = strtoupper($value); + break; } } }