From: herve at moulticast dot net
Operating system: Linux Debian 3.14-1-amd64
PHP version: 5.6.0RC2
Package: FPM related
Bug Type: Bug
Bug description:getallheaders does not clean array keys
Description:
------------
Running Debian with kernel 3.14-1-amd64
Webserver: NginX 1.6.0
PHP: 5.6.0RC2 FPM
The getallheaders() method does not build a clean array.
When trying to access some values via $arr['key'] it doesn't work
because there is a non printable character '0' that is added at the end
of the key.
Test script:
---------------
<?php
// Working example
foreach($_SERVER as $key => $value) {
print('Key: '. $key . ' => ' . $value . "\n");
$key_arr = str_split($key);
foreach($key_arr as $char) {
print($char . ' => ' . ord($char) .' ');
}
print "\n";
}
// Buggy example using getallheaders
$hdrs = getallheaders();
foreach($hdrs as $key => $value) {
print('Key: '. $key . ' => ' . $value . "\n");
$key_arr = str_split($key);
foreach($key_arr as $char) {
print($char . ' => ' . ord($char) .' ');
}
print "\n";
}
?>
Expected result:
----------------
Key for header 'User-Agent' should be (in ASCII):
85 115 101 114 45 65 103 101 110 116
Actual result:
--------------
Key for header 'User-Agent' is (in ASCII):
85 115 101 114 45 65 103 101 110 116 0
--
Edit bug report at https://bugs.php.net/bug.php?id=67642&edit=1
--