Fix bug where some database column length limit could be exceeded (#5291)
Which cased e.g. sql errors when creating a contact group with name > 255 characters.
This commit is contained in:
parent
5ca65962d2
commit
a0aff58604
1 changed files with 10 additions and 2 deletions
|
@ -23,8 +23,9 @@
|
|||
|
||||
class kolab_storage_cache_contact extends kolab_storage_cache
|
||||
{
|
||||
protected $extra_cols = array('type','name','firstname','surname','email');
|
||||
protected $binary_items = array(
|
||||
protected $extra_cols_max = 255;
|
||||
protected $extra_cols = array('type','name','firstname','surname','email');
|
||||
protected $binary_items = array(
|
||||
'photo' => '|<photo><uri>[^;]+;base64,([^<]+)</uri></photo>|i',
|
||||
'pgppublickey' => '|<key><uri>data:application/pgp-keys;base64,([^<]+)</uri></key>|i',
|
||||
'pkcs7publickey' => '|<key><uri>data:application/pkcs7-mime;base64,([^<]+)</uri></key>|i',
|
||||
|
@ -59,6 +60,13 @@ class kolab_storage_cache_contact extends kolab_storage_cache
|
|||
$sql_data['name'] = rcube_charset::clean($object['organization']);
|
||||
}
|
||||
|
||||
// make sure some data is not longer that database limit (#5291)
|
||||
foreach ($this->extra_cols as $col) {
|
||||
if (strlen($sql_data[$col]) > $this->extra_cols_max) {
|
||||
$sql_data[$col] = rcube_charset::clean(substr($sql_data[$col], 0, $this->extra_cols_max));
|
||||
}
|
||||
}
|
||||
|
||||
return $sql_data;
|
||||
}
|
||||
}
|
Loading…
Add table
Reference in a new issue