1
0
mirror of https://github.com/owncloudarchive/contacts.git synced 2024-12-01 13:24:10 +01:00

Prevent multi-bute chars (Emoji) from being added

This commit is contained in:
Thomas Tanghus 2014-03-17 05:58:16 +01:00
parent 8fff8a898a
commit 4da09ff2e7
2 changed files with 17 additions and 1 deletions

View File

@ -1302,6 +1302,18 @@ OC.Contacts = OC.Contacts || {};
if($(this).hasClass('value') && this.value === this.defaultValue) {
return;
}
function isMultiByte(str) {
return /[\uD800-\uDFFF]/.test(str);
}
if (isMultiByte(this.value) && self.getBackend()) {
$(document).trigger('status.contacts.error',
{error:true, message: t('contacts', 'The backend does not support multi-byte characters.')});
if(this.defaultValue) {
this.value = this.defaultValue;
}
return;
}
//console.log('change', this.defaultValue, this.value);
this.defaultValue = this.value;
self.saveProperty({obj:event.target});

View File

@ -187,7 +187,11 @@ class VCard extends VObject\Component\VCard {
if ($options & self::UPGRADE) {
$this->VERSION = self::DEFAULT_VERSION;
foreach($this->children as &$property) {
foreach($this->children as $idx => &$property) {
if (mb_strlen($property->value, 'utf-8') < strlen($property->value)) {
unset($this->children[$idx]);
}
$this->decodeProperty($property);
$this->fixPropertyParameters($property);
/* What exactly was I thinking here?