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
This commit is contained in:
Ralf Becker 2021-10-11 09:50:46 +02:00
parent 59794cc3a4
commit 59a6a3c717

View File

@ -696,10 +696,16 @@ class addressbook_groupdav extends Api\CalDAV\Handler
{ {
trim($attribute); trim($attribute);
list($key, $value) = explode('=', $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)) switch (strtolower($key))
{ {
case 'charset': case 'charset':
$charset = strtoupper(substr($value,1,-1)); $charset = strtoupper($value);
break;
} }
} }
} }