cakePHP: Overload Sanitize
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?
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.
精彩评论