TextFormat: clean() now removes private-use area Unicode characters

the console can't print these, and these are being abused to cause mass crashes in the wild.
This commit is contained in:
Dylan K. Taylor 2019-04-15 18:42:09 +01:00
parent 948b0b4cbc
commit 142d750b9f

View File

@ -87,6 +87,7 @@ abstract class TextFormat{
*/
public static function clean(string $string, bool $removeFormat = true) : string{
$string = mb_scrub($string, 'UTF-8');
$string = preg_replace("/[\x{E000}-\x{F8FF}]/u", "", $string); //remove unicode private-use-area characters (they might break the console)
if($removeFormat){
$string = str_replace(TextFormat::ESCAPE, "", preg_replace("/" . TextFormat::ESCAPE . "[0-9a-fk-or]/u", "", $string));
}