Bug #67642 [Opn]: getallheaders does not clean array keys

From: Date: Thu, 17 Jul 2014 21:44:29 +0000
Subject: Bug #67642 [Opn]: getallheaders does not clean array keys
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-186709@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=67642&edit=1 ID: 67642 Updated by: yohgaki@php.net Reported by: herve at moulticast dot net Summary: getallheaders does not clean array keys Status: Open Type: Bug Package: FPM related Operating System: Linux Debian 3.14-1-amd64 PHP Version: 5.6.0RC2 Block user comment: N Private report: N New Comment: Do you observe trailing NULL chars for all keys? Previous Comments: ------------------------------------------------------------------------ [2014-07-17 15:00:27] herve at moulticast dot net 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 this bug report at https://bugs.php.net/bug.php?id=67642&edit=1

« previous php.bugs (#186709) next »