If this conversion doesn't happen, the HTML will be invalid. If that's what you want, there may be a config option for that.
HTMLPurifier converts > to >
-
11-12-2021 - |
Вопрос
I am using HTMLPurifier with an input textarea where users are allowed to put their HTML tag. Config is default:
$config = HTMLPurifier_Config::createDefault();
$purifier = new HTMLPurifier($config);
$_POST['txt'] = $purifier->purify($_POST['txt']);
The problem I am getting is when the users put some >
in the text, for example:
<p>Some text > other text </p>
This gets converted to:
<p>Some text > other text </p>
Is there any way to stop that conversion? Without doing the oblivious:
$_POST['txt'] = str_replace('>','>',$_POST['txt']);
Решение
Другие советы
as you probably know >
html special character for >
. Browser will render everything properly.
You can try using htmlspecialchars_decode to decode all special chars to original values.
Не связан с StackOverflow