Fix #29707
This commit is contained in:
parent
3bf47e5235
commit
3fcb281d4b
2 changed files with 29 additions and 7 deletions
|
|
@ -2985,11 +2985,12 @@ function removeGlobalParenthesis($string)
|
|||
|
||||
|
||||
/**
|
||||
* Return array of Emojis
|
||||
* Return array of Emojis for miscellaneous use.
|
||||
*
|
||||
* @return array Array of Emojis in hexadecimal
|
||||
* @see getArrayOfEmoji()
|
||||
*/
|
||||
function getArrayOfEmoji()
|
||||
function getArrayOfEmojiBis()
|
||||
{
|
||||
$arrayofcommonemoji = array(
|
||||
'misc' => array('2600', '26FF'), // Miscellaneous Symbols
|
||||
|
|
@ -3019,8 +3020,6 @@ function removeEmoji($text, $allowedemoji = 1)
|
|||
// 0=no emoji, 1=exclude the main known emojis (default), 2=keep only the main known (not implemented), 3=accept all
|
||||
// Note that to accept emoji in database, you must use utf8mb4, utf8mb3 is not enough.
|
||||
|
||||
$arrayofcommonemoji = getArrayOfEmoji();
|
||||
|
||||
if ($allowedemoji == 0) {
|
||||
// For a large removal:
|
||||
$text = preg_replace('/[\x{2600}-\x{FFFF}]/u', '', $text);
|
||||
|
|
@ -3030,6 +3029,8 @@ function removeEmoji($text, $allowedemoji = 1)
|
|||
// Delete emoji chars with a regex
|
||||
// See https://www.unicode.org/emoji/charts/full-emoji-list.html
|
||||
if ($allowedemoji == 1) {
|
||||
$arrayofcommonemoji = getArrayOfEmojiBis();
|
||||
|
||||
foreach ($arrayofcommonemoji as $key => $valarray) {
|
||||
$text = preg_replace('/[\x{'.$valarray[0].'}-\x{'.$valarray[1].'}]/u', '', $text);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -53,6 +53,28 @@ if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO'])) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Return array of Emojis. We can't move this function inside a common lib because we need it for security before loading any file.
|
||||
*
|
||||
* @return array Array of Emojis in hexadecimal
|
||||
* @see getArrayOfEmojiBis()
|
||||
*/
|
||||
function getArrayOfEmoji()
|
||||
{
|
||||
$arrayofcommonemoji = array(
|
||||
'misc' => array('2600', '26FF'), // Miscellaneous Symbols
|
||||
'ding' => array('2700', '27BF'), // Dingbats
|
||||
'????' => array('9989', '9989'), // Variation Selectors
|
||||
'vars' => array('FE00', 'FE0F'), // Variation Selectors
|
||||
'pict' => array('1F300', '1F5FF'), // Miscellaneous Symbols and Pictographs
|
||||
'emot' => array('1F600', '1F64F'), // Emoticons
|
||||
'tran' => array('1F680', '1F6FF'), // Transport and Map Symbols
|
||||
'flag' => array('1F1E0', '1F1FF'), // Flags (note: may be 1F1E6 instead of 1F1E0)
|
||||
'supp' => array('1F900', '1F9FF'), // Supplemental Symbols and Pictographs
|
||||
);
|
||||
|
||||
return $arrayofcommonemoji;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the real char for a numeric entities.
|
||||
|
|
@ -72,13 +94,12 @@ function realCharForNumericEntities($matches)
|
|||
$newstringnumentity = (int) $newstringnumentity;
|
||||
}
|
||||
|
||||
// The numeric value we don't want as entities because they encode ascii char, and why using html entities on ascii except for haking ?
|
||||
// The numeric values we don't want as entities because they encode ascii char, and why using html entities on ascii except for haking ?
|
||||
if (($newstringnumentity >= 65 && $newstringnumentity <= 90) || ($newstringnumentity >= 97 && $newstringnumentity <= 122)) {
|
||||
return chr((int) $newstringnumentity);
|
||||
}
|
||||
|
||||
// The numeric value we want in UTF8 instead of entities because it is emoji
|
||||
include_once DOL_DOCUMENT_ROOT.'/core/lib/functions2.lib.php';
|
||||
// The numeric values we want in UTF8 instead of entities because it is emoji
|
||||
$arrayofemojis = getArrayOfEmoji();
|
||||
foreach ($arrayofemojis as $valarray) {
|
||||
if ($newstringnumentity >= hexdec($valarray[0]) && $newstringnumentity <= hexdec($valarray[1])) {
|
||||
|
|
|
|||
Loading…
Reference in a new issue