diff --git a/htdocs/core/lib/functions.lib.php b/htdocs/core/lib/functions.lib.php index 03a42beff2a..c3417702c6a 100644 --- a/htdocs/core/lib/functions.lib.php +++ b/htdocs/core/lib/functions.lib.php @@ -970,7 +970,7 @@ function dol_string_unaccent($str) * @param array $badcharstoreplace List of forbidden characters * @return string Cleaned string * - * @see dol_sanitizeFilename(), dol_string_unaccent() + * @see dol_sanitizeFilename(), dol_string_unaccent(), dol_string_nounprintableascii() */ function dol_string_nospecial($str, $newstr = '_', $badcharstoreplace = '') { @@ -983,6 +983,21 @@ function dol_string_nospecial($str, $newstr = '_', $badcharstoreplace = '') } +/** + * Clean a string from all non printable ascii chars (0x00-0x1F and 0x7F). It removes also CR-LF + * This can be used to sanitize a string and view its real content. Some hacks try to obfuscate attacks by inserting non printable chars. + * + * @param string $str String to clean + * @return string Cleaned string + * + * @see dol_sanitizeFilename(), dol_string_unaccent(), dol_string_nospecial() + */ +function dol_string_nounprintableascii($str) +{ + return preg_replace('/[\x00-\x1F\x7F]/u', '', $str); +} + + /** * Returns text escaped for inclusion into javascript code * diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index e584ad48a42..b46a72b5ddc 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -57,11 +57,13 @@ if (!empty($_SERVER['MAIN_SHOW_TUNING_INFO'])) */ function testSqlAndScriptInject($val, $type) { - $val = html_entity_decode($val, ENT_QUOTES); // So message; include_once DOL_DOCUMENT_ROOT.'/core/class/doleditor.class.php'; $uselocalbrowser = true; - $doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser, $conf->global->FCKEDITOR_ENABLE_TICKET, ROWS_9, '95%'); + $ckeditorenabledforticket = $conf->global->FCKEDITOR_ENABLE_TICKET; + $doleditor = new DolEditor('message_initial', $msg, '100%', 250, 'dolibarr_details', 'In', true, $uselocalbrowser, $ckeditorenabledforticket, ROWS_9, '95%'); $doleditor->Create(); } else { // Deal with format differences (text / HTML)