swapped htmlentities() by the Security equivalent to fix issues with PHP 5.3. Closes #1296