views:

42

answers:

1

In the recent cakePHP 1.3.4 version I discovered that Sanitize::html returns double encoded html entities - because of the newly added fourth parameter of htmlentities 'double_encode'.

Here is a corresponding ticket on cakePHP: http://cakephp.lighthouseapp.com/projects/42648/tickets/1152-sanitizehtml-needs-double_encode-parameter-in-htmlentities

Since I need to use cakePHP 1.3.4 on PHP 5.2.14 I need to change the double_encode parameter. Is there a way to overload the Sanitize::html method in cake so I don't have to fiddle with the core?

+1  A: 

You can subclass it in the /app/libs directory:

App::import('Sanitize');

class MySanitize extends Sanitize {

    public static function html(...) {
        ...
    }

}

You'll have to switch to use MySanitize instead of Sanitize, but that shouldn't be a big problem. A text find/replace can take care of it if you're using it a lot already.

deceze
Thank you very much - subclassed it is :)
lorem monkey