php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #76954 Function apache_response_headers removes last character from header name
Submitted: 2018-10-01 04:53 UTC Modified: 2018-10-08 10:35 UTC
Votes:1
Avg. Score:3.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: sasa dot todorovic101 at gmail dot com Assigned: cmb (profile)
Status: Closed Package: CGI/CLI related
PHP Version: 7.* OS: Linux
Private report: No CVE-ID: None
 [2018-10-01 04:53 UTC] sasa dot todorovic101 at gmail dot com
Description:
------------
This function works correctly in PHP 5.x, but in PHP 7.x(sapi CGI) last characters from header's names are removed.

More details - https://github.com/Automattic/wp-super-cache/issues/539


Test script:
---------------
<?php

header( 'Link: <http://www.example.com/wp-json>; rel="https://api.w.org/"' );
header( 'X-Robots-Tag: noindex,nofollow,noarchive' );

echo '<html><body><pre>';

foreach ( apache_response_headers() as $hdr_key => $hdr_val ) {
        echo $hdr_key . ' => ' . htmlentities( $hdr_val ) . PHP_EOL;
}

echo '</pre></body></html>';


Expected result:
----------------
X-Powered-By => PHP/7.2.10
Link => <http://www.example.com/wp-json>; rel="https://api.w.org/"
X-Robots-Tag => noindex,nofollow,noarchive
Content-type => text/html; charset=UTF-8


Actual result:
--------------
X-Powered-B => PHP/7.2.10
Lin => <http://www.example.com/wp-json>; rel="https://api.w.org/"
X-Robots-Ta => noindex,nofollow,noarchive
Content-typ => text/html; charset=UTF-8


Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-10-01 06:36 UTC] sasa dot todorovic101 at gmail dot com
Added PR https://github.com/php/php-src/pull/3566 (I use comment because 'Add a Pull Request' doesn't work).
 [2018-10-04 05:10 UTC] sasa dot todorovic101 at gmail dot com
-PHP Version: 7.2.10 +PHP Version: 7.*
 [2018-10-04 05:10 UTC] sasa dot todorovic101 at gmail dot com
It's related to all PHP 7 versions.
 [2018-10-04 12:23 UTC] kalle@php.net
-Status: Open +Status: Feedback
 [2018-10-04 12:23 UTC] kalle@php.net
Can you confirm if this also happens for the apache_request_headers() function?
 [2018-10-04 12:25 UTC] kalle@php.net
-Status: Feedback +Status: Open
 [2018-10-04 12:25 UTC] kalle@php.net
Ah my mistake, I just noticed the CGI SAPI (I was first under the impression that it was using the apache2handler SAPI)
 [2018-10-08 07:39 UTC] sasa dot todorovic101 at gmail dot com
I didn't notice similar issues related to other functions. Even, php_cli_server uses while loop in apache_response_headers() and it returns correct headers.
Also, headers_list() returns correct headers and I've created workaround for WPSC - https://github.com/Automattic/wp-super-cache/pull/618
 [2018-10-08 10:34 UTC] cmb@php.net
Automatic comment on behalf of sasa.todorovic@gmx.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=47b89bc5314534e4aab4a8d6cda0da9d079366f6
Log: Fix #76954: apache_response_headers removes last character from header name
 [2018-10-08 10:34 UTC] cmb@php.net
-Status: Open +Status: Closed
 [2018-10-08 10:35 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC