1

在最近的 cakePHP 1.3.4 版本中,我发现 Sanitize::html 返回双重编码的 html 实体 - 因为新添加的 htmlentities 'double_encode' 的第四个参数。

这是 cakePHP 的相应票证:http: //cakephp.lighthouseapp.com/projects/42648/tickets/1152-sanitizehtml-needs-double_encode-parameter-in-htmlentities

由于我需要在 PHP 5.2.14 上使用 cakePHP 1.3.4,我需要更改 double_encode 参数。有没有办法重载蛋糕中的 Sanitize::html 方法,这样我就不必摆弄核心了?

4

1 回答 1

2

您可以在/app/libs目录中对其进行子类化:

App::import('Sanitize');

class MySanitize extends Sanitize {

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

}

您必须切换到 useMySanitize而不是Sanitize,但这应该不是什么大问题。如果您已经大量使用它,文本查找/替换可以处理它。

于 2010-09-29T07:28:06.047 回答