Skip to content

Commit

Permalink
Bugfix: Template content being 'escaped' showing HTML entities
Browse files Browse the repository at this point in the history
  • Loading branch information
Maaiins committed Feb 28, 2020
1 parent 75ca1ed commit 08a5b45
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions modules/base/classes/sanitize.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,20 @@ public static function escapeForDisplay($string, $encoding = 'UTF-8', $quotes =
//use mode to ocnvert both single and double quotes.
$quotes = ENT_QUOTES;
}

return htmlentities($string, $quotes, $encoding);

// revert special chars, some values are saved encoded in the database eg. page title
$string = html_entity_decode($string, $quotes);

// replace all html tags, to prevent encoding
$string = preg_replace('#\<(.*?)\>(.*?)\</(.*?)\>#', '[html_open]\\1[html_close]\\2[html_open]/\\3[html_close]', $string);

$string = htmlentities($string, $quotes, $encoding);

// recover html
$string = str_replace('[html_open]', '<', $string);
$string = str_replace('[html_close]', '>', $string);

return $string;
}


Expand Down

0 comments on commit 08a5b45

Please sign in to comment.