Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xss_clean % error #6252

Open
pascaadryan opened this issue Dec 1, 2023 · 1 comment
Open

xss_clean % error #6252

pascaadryan opened this issue Dec 1, 2023 · 1 comment

Comments

@pascaadryan
Copy link

I think I found a problem with xss_clean function. I this code section (Security.php):

f (stripos($str, '%') !== false) {
do {
$oldstr = $str;
$str = rawurldecode($str);
$str = preg_replace_callback('#%(?:\s*[0-9a-f]){2,}#i', [$this, '_urldecodespaces'], $str);
} while ($oldstr !== $str);
unset($oldstr);
}

I have an input text, I send the following string: 60% acqua via post. If you try to encode UTF8 the result is 60¬qua because the blanks are removed and the utf8_encode found %ac and makes the conversion into ¬ . The issue is when a sequence of chars identifies ASCII CODE (for example: 90% cars is converted in 90Êrs).

I have changed f (stripos($str, '%') !== false) { in if (preg_match('~%[0-9A-F]{2}~i', $str) > 0) { to check if the string is an urlecoded. It works but I'm not sure 100% that is correct.

@kenjis
Copy link
Contributor

kenjis commented Dec 1, 2023

Using xss_clean() is a bad practice in the past.
See https://forum.codeigniter.com/showthread.php?tid=75338&pid=371462#pid371462

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants