mirror of
https://github.com/itflow-org/itflow
synced 2026-03-09 07:14:51 +00:00
Merge pull request #1067 from itflow-org/encoding
Detect and convert non-UTF8 encoding as part of input sanitization
This commit is contained in:
@@ -733,6 +733,14 @@ function sanitizeInput($input)
|
|||||||
{
|
{
|
||||||
global $mysqli;
|
global $mysqli;
|
||||||
|
|
||||||
|
// Detect encoding
|
||||||
|
$encoding = mb_detect_encoding($input, ['UTF-8', 'ISO-8859-1', 'Windows-1252', 'ISO-8859-15'], true);
|
||||||
|
|
||||||
|
// If not UTF-8, convert to UTF8 (primarily Windows-1252 is problematic)
|
||||||
|
if ($encoding !== 'UTF-8') {
|
||||||
|
$input = mb_convert_encoding($input, 'UTF-8', $encoding);
|
||||||
|
}
|
||||||
|
|
||||||
// Remove HTML and PHP tags
|
// Remove HTML and PHP tags
|
||||||
$input = strip_tags((string) $input);
|
$input = strip_tags((string) $input);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user