MDL-84907 backup: Fix invalid CTRL characters regex

This commit is contained in:
Huong Nguyen
2025-03-19 09:22:36 +07:00
parent c64e967ce6
commit d3eef51ef7
6 changed files with 25 additions and 12 deletions
+12
View File
@@ -668,4 +668,16 @@ class core_text {
return mb_convert_case($text, MB_CASE_TITLE, 'UTF-8');
}
/**
* Trims control characters out of a string.
* Example: (\x00-\x1f) and (\x7f)
*
* @param string $text Input string
* @return string Cleaned string value
*/
public static function trim_ctrl_chars(string $text): string {
// Remove control characters text.
return preg_replace('/[\x00-\x08\x0b-\x0c\x0e-\x1f\x7f]/i', '', $text);
}
}