mirror of https://github.com/MISP/MISP
fix: [unicode] Temporarily escape 4 byte characters until we move the attribute value fields to mb4, fixes #5123
- fixes sync/feed issues related to 4 byte unicode characterspull/6172/head
parent
69c3234005
commit
a2c0010d48
|
@ -2914,7 +2914,23 @@ class AppModel extends Model
|
|||
if (!is_array($decoded)) {
|
||||
throw new UnexpectedValueException('JSON must be array type, get ' . gettype($decoded));
|
||||
}
|
||||
|
||||
return $decoded;
|
||||
}
|
||||
|
||||
/*
|
||||
* Temporary solution for utf8 columns until we migrate to utf8mb4
|
||||
* via https://stackoverflow.com/questions/16496554/can-php-detect-4-byte-encoded-utf8-chars
|
||||
*/
|
||||
public function handle4ByteUnicode($input)
|
||||
{
|
||||
return preg_replace(
|
||||
'%(?:
|
||||
\xF0[\x90-\xBF][\x80-\xBF]{2}
|
||||
| [\xF1-\xF3][\x80-\xBF]{3}
|
||||
| \xF4[\x80-\x8F][\x80-\xBF]{2}
|
||||
)%xs',
|
||||
'?',
|
||||
$input
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1467,6 +1467,7 @@ class Attribute extends AppModel
|
|||
// do some last second modifications before the validation
|
||||
public function modifyBeforeValidation($type, $value)
|
||||
{
|
||||
$value = $this->handle4ByteUnicode($value);
|
||||
switch ($type) {
|
||||
case 'md5':
|
||||
case 'sha1':
|
||||
|
|
Loading…
Reference in New Issue