Page MenuHomePhabricator

Fix HTTP body decompression in PHP 5.6
ClosedPublic

Authored by epriestley on Feb 20 2016, 7:55 PM.
Tags
None
Referenced Files
F14048293: D15314.diff
Thu, Nov 14, 7:22 AM
F14037409: D15314.diff
Sun, Nov 10, 3:43 PM
F14019144: D15314.diff
Tue, Nov 5, 9:37 PM
F13997747: D15314.diff
Thu, Oct 24, 5:59 AM
F13986875: D15314.id36939.diff
Mon, Oct 21, 6:03 AM
Unknown Object (File)
Oct 12 2024, 6:30 PM
Unknown Object (File)
Sep 19 2024, 3:17 AM
Unknown Object (File)
Sep 19 2024, 3:00 AM
Subscribers
None

Details

Summary

Ref T10264. Under PHP 5.6, you are no longer allowed to use compress.zlib://php://input as an argument to either fopen() or file_get_contents().

Instead, open php://input as a file handle, then add zlib.inflate as a stream wrapper. This requires some level of magic to work properly.

Test Plan

First, I constructed a synthetic gzipped payload by typing some words into a file and using gzcompress() to compress it.

Then I used a curl command like this to make requests with it:

$ curl -X POST -H "Content-Length: 66" -H "Content-Type: text/plain" -H "Content-Encoding: gzip" --data-binary @payload.deflate -v http://127.0.0.1/

I modified Phabricator to just dump the raw request body and exit, and reproduced the issue under PHP 5.6 (no body, error in log) by brining up a micro instance in EC2 and installing php56 on it.

After this patch, it dumped the body properly instead, and PHP 5.5 also continued worked properly.

Diff Detail

Repository
rP Phabricator
Branch
gzip56
Lint
Lint Passed
Unit
No Test Coverage
Build Status
Buildable 10783
Build 13276: Run Core Tests
Build 13275: arc lint + arc unit

Event Timeline

epriestley retitled this revision from to Fix HTTP body decompression in PHP 5.6.
epriestley updated this object.
epriestley edited the test plan for this revision. (Show Details)
epriestley added a reviewer: chad.
chad edited edge metadata.
This revision is now accepted and ready to land.Feb 20 2016, 9:47 PM
This revision was automatically updated to reflect the committed changes.