Welcome! » Log In » Create A New Profile

Purifier returns nothing on production server

Posted by Ryan 


I recently inherited some code at a new company that worked up until we upgraded to PHP 7.1.0. Now my dev environment works beautifully with the code and closes a missing "strong" tag, but once I push it to production, it dies and returns nothing. I can't figure out where it's going wrong, and wondering if you can take a look. Here's the code in question:

if (!function_exists('purify_html')) {
    function purify_html($dirty_html) {
      $config = HTMLPurifier_Config::createDefault();
      $config->set('Cache.DefinitionImpl', null); /* Disable cache because it requires chmodding */
      $purifier = new HTMLPurifier($config);
      return $purifier->purify($dirty_html);

Any ideas? Let me know.

Re: Purifier returns nothing on production server
May 16, 2017 09:53PM

We are attempting to debug an infinite loop on PHP 7 at https://github.com/ezyang/htmlpurifier/issues/134 ; perhaps the symptoms coincide?

Otherwise, it will be difficult for me to meaningfully helpful if you can't turn up with some error logs.


HTML input is enabled. Make sure you escape all HTML and angled brackets with < and >.

Auto-paragraphing is enabled. Double newlines will be converted to paragraphs; for single newlines, use the pre tag.

Allowed tags: a, abbr, acronym, b, blockquote, caption, cite, code, dd, del, dfn, div, dl, dt, em, i, ins, kbd, li, ol, p, pre, s, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, var.

For inputting literal code such as HTML and PHP for display, use CDATA tags to auto-escape your angled brackets, and pre to preserve newlines:

Place code here

Power users, you can hide this notice with:

.htmlpurifier-help {display:none;}