是否有任何服务器设置可以修复调用 file_get_contents 时的 addslashes 行为
直到大约一周前,我们主机上的 WordPress 网站还没有出现任何问题。
然而,从今天早上开始,我们注意到一个问题,即管理页面无法在 WordPress 中加载。在同一服务器上的其他站点上,一个站点的一页显示的所有单引号和双引号前面都带有反斜杠,例如 \" 和 \'。我们检查并发现更多使用 file_get_contents 的站点也遇到了同样的问题。
我们问我们的主持人,他说这是一个 mod_security 问题,但是对相关页面关闭它没有效果。直接将 stripslashes() 添加到非 WordPress 网站上最关键页面和函数的输出中可以再次获得可接受的渲染。
然而,我们应该要求主机设置(或者我们可以设置,因为我们可以通过 ssh 访问服务器)来解决这个问题,而不是在 WordPress 中进行修改,
有谁知道哪种设置可能会导致 这个问题?这个函数可以在内容中添加斜杠吗?
我尝试通过 php.ini 禁用斜杠,但它不会改变这些网站上的行为,
任何想法。
欢迎
Up until about a week ago, wordpress websites on our host showed no issues.
However, since this morning we noticed an issue whereby admin pages failed to load in wordpress. On other sites on the same server one page of one site was being displayed with all single and double quotes preceded with a backslash like this, \" and \'. We checked and found more sites using file_get_contents are suffering from the same issue.
We asked our host, who said it was a mod_security issue, but turning it off for the relevant pages has no effect. Adding stripslashes() directly to the output of the most critical pages and functions on non-wordpress sites got those rendering acceptably again.
However, rather than hacking around in wordpress, is there any setting that we should be asking the host to set (or that we can set since we have ssh access to the server) that can address this issue?
Does anyone know what kind of setting might cause this function to add slashes to content?
I tried disabling slashes via php.ini but it doesn't change the behaviour on those sites.
Any thoughts for where to start are welcome.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
谁告诉你这是 mod_security 的人都是错误的。这是一个 PHP 设置 magic_quotes_gpc,它控制是否将斜杠添加到输入中。它已被弃用多年,并且应该始终关闭。如果它已打开,那么您可能可以覆盖它并使用 .htaccess 文件再次将其关闭,但如果这不是一个选项,您将不得不要求您的主机检查 magic_quotes_gpc 设置。
Whoever told you it was mod_security is wrong. It's a PHP setting, magic_quotes_gpc, which controlls whether slashes are added to input. It's been deprecated for some years now, and should always be off. If it's on then you might be able to override it and turn it off again with a .htaccess file, but if that's not an option you'll have to ask your host to check the magic_quotes_gpc setting.