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 2e1f6a983f
commit d5654e8178

View File

@ -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;
}
}
}