Correctly truncate multibyte strings to fit into the database
Closes: #26174 Signed-off-by: Chih-Hsuan Yen <yan12125@gmail.com>
This commit is contained in:
parent
bf9ed2d3cd
commit
fea5b4a8b9
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue