问题在于AssetDispatcher 过滤器,它包含css 和js 使用PHP 语句的文件include() 语句,导致文件通过PHP 解析器发送,在那里它会偶然发现@987654328 的出现@在 TinyMCE 脚本中。
见https://github.com/.../2.4.7/lib/Cake/Routing/Filter/AssetDispatcher.php#L159-L160
如果你问我,这是一个非常烦人的,而且,因为它是无证和非可选的,危险的行为。
自定义资产调度器
如果您想继续使用插件资产调度程序,请扩展内置的,并重新实现 AssetDispatcher::_deliverAsset() 方法并删除包含功能。当然,这有点烦人,维护明智,但这是一个非常快速的解决方案。
类似:
// app/Routing/Filter/MyAssetDispatcher.php
App::uses('AssetDispatcher', 'Routing/Filter');
class MyAssetDispatcher extends AssetDispatcher {
protected function _deliverAsset(CakeResponse $response, $assetFile, $ext) {
// see the source of your CakePHP core for the
// actual code that you'd need to reimpelment
ob_start();
$compressionEnabled = Configure::read('Asset.compress') && $response->compress();
if ($response->type($ext) == $ext) {
$contentType = 'application/octet-stream';
$agent = env('HTTP_USER_AGENT');
if (preg_match('%Opera(/| )([0-9].[0-9]{1,2})%', $agent) || preg_match('/MSIE ([0-9].[0-9]{1,2})/', $agent)) {
$contentType = 'application/octetstream';
}
$response->type($contentType);
}
if (!$compressionEnabled) {
$response->header('Content-Length', filesize($assetFile));
}
$response->cache(filemtime($assetFile));
$response->send();
ob_clean();
// instead of the possible `include()` in the original
// methods source, use `readfile()` only
readfile($assetFile);
if ($compressionEnabled) {
ob_end_flush();
}
}
}
// app/Config/bootstrap.php
Configure::write('Dispatcher.filters', array(
'MyAssetDispatcher', // instead of AssetDispatcher
// ...
));
另见http://book.cakephp.org/2.0/en/development/dispatch-filters.html
不要只禁用短打开标签
我只是在这里猜测,但它在您的其他服务器上工作的原因可能是 short open tags(即<?)被禁用。但是,即使这是您的新服务器上的问题,这也不是您应该依赖的,资产仍在使用include() 提供服务,您很可能不想检查所有第三方 CSS/JS用于每次更新时可能的 PHP 代码注入。