在 php 5.5.1/apache 2.4.6 中忽略带有下划线的标题名称

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 中忽略带有下划线的标题名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

升级到 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 中忽略带有下划线的标题名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

Convert JSON integers and floats to strings(将JSON整数和浮点数转换为字符串)
in php how do I use preg replace to turn a url into a tinyurl(在php中,如何使用preg替换将URL转换为TinyURL)
all day appointment for ics calendar file wont work(ICS日历文件的全天约会不起作用)
trim function is giving unexpected values php(Trim函数提供了意外的值php)
Basic PDO connection to MySQL(到MySQL的基本PDO连接)
PHP number_format returns 1.00(Php number_Format返回1.00)