php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #78792 zlib.output_compression disabled by Content-Type: image/
Submitted: 2019-11-07 17:09 UTC Modified: 2020-09-23 21:58 UTC
From: ewgenij dot starostin at foo dot ag Assigned: cmb (profile)
Status: Closed Package: Zlib related
PHP Version: 7.4.0RC5 OS:
Private report: No CVE-ID: None
View Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
If you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: ewgenij dot starostin at foo dot ag
New email:
PHP Version: OS:

 

 [2019-11-07 17:09 UTC] ewgenij dot starostin at foo dot ag
Description:
------------
From PHP 4.3.2 onward until and including 7.4, setting zlib.output_compression to On and then sending a Content-Type header whose value begins with image/ leads to zlib.output_compression being reset to 0.

Old copies of the documentation (e. g. https://www.macs.hw.ac.uk/~hwloidl/docs/PHP/ref.zlib.html) describe this behaviour, which is a fix for bug #16109:
> If you output a "Content-Type: image/" header the compression is disabled, too
> (in order to circumvent a Netscape bug). You can reenable it, if you add
> "ini_set('zlib.output_compression', 'On')" after the header call which added the
> image content-type.

Granting that it was intentional, is anyone even using an original Netscape user agent anymore and is affected by their bug? (Bug 16109 was reproducible with Nescape Communicator 4.79…)

Otherwise, the relevant lines in main/SAPI.c sapi_header_op() (original commit 6f786ebf3e) could be removed and save everyone the hassle of working around this — in a large code base, figuring out when a header might be sent with the value having a specific prefix and adding ini_get()/ini_set() calls at every such point is just annoying. Apart from Netscape Navigator/Communicator users, nobody should be adversely affected by the change.

Test script:
---------------
<?php
// https://3v4l.org/2tV5T
ini_set('zlib.output_compression', 'On');
$v = ini_get('zlib.output_compression');
header('Content-Type: image/svg+xml');
var_dump($v, ini_get('zlib.output_compression'));

Expected result:
----------------
string(2) "On"
string(2) "On"

Actual result:
--------------
string(2) "On"
string(1) "0"

Patches

revert-fix-for-bug-16109.patch (last revision 2019-11-07 17:11 UTC by ewgenij dot starostin at foo dot ag)

Pull Requests

Pull requests:

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2019-11-07 17:11 UTC] ewgenij dot starostin at foo dot ag
The following patch has been added/updated:

Patch Name: revert-fix-for-bug-16109.patch
Revision:   1573146666
URL:        https://bugs.php.net/patch-display.php?bug=78792&patch=revert-fix-for-bug-16109.patch&revision=1573146666
 [2020-09-23 21:56 UTC] cmb@php.net
The following pull request has been associated:

Patch Name: Fix #78792: zlib.output_compression disabled by Content-Type: image/
On GitHub:  https://github.com/php/php-src/pull/6198
Patch:      https://github.com/php/php-src/pull/6198.patch
 [2020-09-23 21:58 UTC] cmb@php.net
-Assigned To: +Assigned To: cmb
 [2020-09-29 09:30 UTC] cmb@php.net
Automatic comment on behalf of cmbecker69@gmx.de
Revision: http://git.php.net/?p=php-src.git;a=commit;h=47a166c8378e8e670994f272c7f948b67014c619
Log: Fix #78792: zlib.output_compression disabled by Content-Type: image/
 [2020-09-29 09:30 UTC] cmb@php.net
-Status: Assigned +Status: Closed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Dec 03 17:01:29 2024 UTC