Merge pull request #26755 from yan12125/bugfix/yan12125/caldav-truncation

Correctly truncate multibyte strings to fit into the database
This commit is contained in:
Christoph Wurst 2021-04-26 11:56:26 +02:00 committed by GitHub
commit 8f3a0705d4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 4 deletions

View File

@ -2678,7 +2678,7 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
if (!$this->db->supports4ByteText()) {
$value = preg_replace('/[\x{10000}-\x{10FFFF}]/u', "\xEF\xBF\xBD", $value);
}
$value = mb_substr($value, 0, 254);
$value = mb_strcut($value, 0, 254);
$query->setParameter('name', $property->name);
$query->setParameter('parameter', null);
@ -2698,8 +2698,8 @@ class CalDavBackend extends AbstractBackend implements SyncSupport, Subscription
}
$query->setParameter('name', $property->name);
$query->setParameter('parameter', mb_substr($key, 0, 254));
$query->setParameter('value', mb_substr($value, 0, 254));
$query->setParameter('parameter', mb_strcut($key, 0, 254));
$query->setParameter('value', mb_strcut($value, 0, 254));
$query->executeUpdate();
}
}

View File

@ -1271,7 +1271,7 @@ class CardDavBackend implements BackendInterface, SyncSupport {
}
}
$query->setParameter('name', $property->name);
$query->setParameter('value', mb_substr($property->getValue(), 0, 254));
$query->setParameter('value', mb_strcut($property->getValue(), 0, 254));
$query->setParameter('preferred', $preferred);
$query->execute();
}