-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
NEW Add function to manipulate emojis
- Loading branch information
Showing
6 changed files
with
175 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,23 +58,35 @@ | |
* Return the real char for a numeric entities. | ||
* WARNING: This function is required by testSqlAndScriptInject() and the GETPOST 'restricthtml'. Regex calling must be similar. | ||
* | ||
* @param string $matches String of numeric entity | ||
* @return string New value | ||
* @param array<int:string> $matches Array with a decimal numeric entity into key 0, value without the &# into the key 1 | ||
Check warning on line 61 in htdocs/main.inc.php GitHub Actions / phan / Run phan
Check warning on line 61 in htdocs/main.inc.php GitHub Actions / phan / Run phan
|
||
* @return string New value | ||
*/ | ||
function realCharForNumericEntities($matches) | ||
{ | ||
$newstringnumentity = preg_replace('/;$/', '', $matches[1]); | ||
//print ' $newstringnumentity='.$newstringnumentity; | ||
|
||
if (preg_match('/^x/i', $newstringnumentity)) { | ||
if (preg_match('/^x/i', $newstringnumentity)) { // if numeric is hexadecimal | ||
$newstringnumentity = hexdec(preg_replace('/^x/i', '', $newstringnumentity)); | ||
} else { | ||
$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 ? | ||
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'; | ||
$arrayofemojis = getArrayOfEmoji(); | ||
foreach ($arrayofemojis as $valarray) { | ||
if ($newstringnumentity >= hexdec($valarray[0]) && $newstringnumentity <= hexdec($valarray[1])) { | ||
// This is a known emoji | ||
return html_entity_decode($matches[0], ENT_COMPAT | ENT_HTML5, 'UTF-8'); | ||
} | ||
} | ||
|
||
return '&#'.$matches[1]; // Value will be unchanged because regex was /&#( )/ | ||
} | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters