ezyang / htmlpurifier

Standards compliant HTML filter written in PHP
http://htmlpurifier.org
GNU Lesser General Public License v2.1
3.03k stars 323 forks source link

Lost case of text when using Core.EscapeInvalidTags #314

Open andreybatalof opened 2 years ago

andreybatalof commented 2 years ago

Hello!

Let's check following code:

$allowedTagsList = [
            'a',
            'p',
            'div',
        ];

$config = HTMLPurifier_Config::createDefault();
$config->set('Core.EscapeInvalidTags', true);
$config->set('HTML.AllowedElements', $allowedTagsList);
$purifier = new HTMLPurifier($config);
$htmlBody = $purifier->purify($htmlBody);

$htmlBody before purifying <p>Hello! I want attach following xml:</p><p><someGreatTag>someGreatValue</someGreatTag></p>

Expected after purifying <p>Hello! I want attach following xml:</p><p>&lt;someGreatTag&gt;someGreatValue&lt;/someGreatTag&gt;</p>

But in reality <p>Hello! I want attach following xml:</p><p>&lt;somegreattag&gt;someGreatValue&lt;/somegreattag&gt;</p>

So, any denied tag lose capitalization (someGreatTag -> somegreattag)

php 7.4.27 htmlpurifier 4.14.0