From 71bda66870d8ef832f4d048b11282f9ae0086f05 Mon Sep 17 00:00:00 2001 From: epriestley Date: Sat, 30 Jan 2016 16:44:33 -0800 Subject: [PATCH] (stable) Decode "Content-Encoding: gzip" content Summary: Fixes T10228. When we receive a gzipped request (rare, but `git` may send them), decode it before providing it to the application. This fixes the issue with proxying certain requests described in T10228. Test Plan: - Applied this fix in production. - Cloned a problem repository cleanly. Reviewers: chad Reviewed By: chad Maniphest Tasks: T10228 Differential Revision: https://secure.phabricator.com/D15145 --- support/PhabricatorStartup.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/support/PhabricatorStartup.php b/support/PhabricatorStartup.php index 198cc1b244..bc7daf4ea6 100644 --- a/support/PhabricatorStartup.php +++ b/support/PhabricatorStartup.php @@ -129,7 +129,19 @@ final class PhabricatorStartup { self::beginOutputCapture(); - self::$rawInput = (string)file_get_contents('php://input'); + if (isset($_SERVER['HTTP_CONTENT_ENCODING'])) { + $encoding = trim($_SERVER['HTTP_CONTENT_ENCODING']); + } else { + $encoding = null; + } + + if ($encoding === 'gzip') { + $source_stream = 'compress.zlib://php://input'; + } else { + $source_stream = 'php://input'; + } + + self::$rawInput = (string)file_get_contents($source_stream); }