Header names with underscores ignored in php 5.5.1 / apache 2.4.6(在 php 5.5.1/apache 2.4.6 中忽略带有下划线的标题名称)
问题描述
升级到 php 5.5.1 和 apache 2.4.6 后,检查某些标头现在已损坏(特别是检查 HTTP_X_REQUESTED_WITH).
After upgrading to php 5.5.1 and apache 2.4.6, checking for certain headers is now broken (specifically, checking for HTTP_X_REQUESTED_WITH).
通过进一步的测试,我注意到任何包含下划线的自定义标头都会被忽略(我的意思是它不会出现在 PHP 的 $_SERVER 数组中).因此,如果我添加一个名为 my-header 的标头,它会以 $_SERVER['HTTP_MY_HEADER'] 的形式使用,但如果我尝试添加一个标头 my_header,它在 $_SERVER 中不可用.
Through further testing I noticed that any custom header that contains an underscore is ignored (by this I mean it does not show up in PHP's $_SERVER array). So if I add a header named my-header, it becomes available as $_SERVER['HTTP_MY_HEADER'], but if I try adding a header my_header, it's not available in $_SERVER.
推荐答案
这是 apache 2.4 中记录的功能.请参阅 httpd.apache.org/docs/trunk/new_features_2_4.html
This is a documented feature in apache 2.4. See httpd.apache.org/docs/trunk/new_features_2_4.html
将标头转换为环境变量比在通过以下方式减轻一些可能的跨站点脚本攻击之前标头注入.包含无效字符的标头(包括下划线)现在被静默删除.
Translation of headers to environment variables is more strict than before to mitigate some possible cross-site-scripting attacks via header injection. Headers containing invalid characters (including underscores) are now silently dropped.
这篇关于在 php 5.5.1/apache 2.4.6 中忽略带有下划线的标题名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在 php 5.5.1/apache 2.4.6 中忽略带有下划线的标题名称
基础教程推荐
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
