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: -
From: ewgenij dot starostin at foo dot ag Assigned:
Status: Open Package: Zlib related
PHP Version: 7.4.0RC5 OS:
Private report: No CVE-ID: None
Have you experienced this issue?
Rate the importance of this bug to you:

 [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)

Add a Patch

Pull Requests

Add a Pull Request

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
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Sat Dec 14 20:01:23 2019 UTC