From 3c3e00a74f77ae367e6e7d8ad26e6496c70cd8bf Mon Sep 17 00:00:00 2001 From: epriestley Date: Tue, 22 Jan 2013 17:17:37 -0800 Subject: [PATCH] Raise early fatal for bad rewrite with no "/" Summary: This particular misconfiguration results in a difficult-to-debug redirect loop, so stop it early. Test Plan: Broke my rewrite rule, verified I got yelled at. Reviewers: btrahan, chad Reviewed By: chad CC: aran Differential Revision: https://secure.phabricator.com/D4591 --- support/PhabricatorStartup.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/support/PhabricatorStartup.php b/support/PhabricatorStartup.php index b428b53f4a..5b0d266e97 100644 --- a/support/PhabricatorStartup.php +++ b/support/PhabricatorStartup.php @@ -221,7 +221,7 @@ final class PhabricatorStartup { * @task valiation */ private static function verifyRewriteRules() { - if (isset($_REQUEST['__path__'])) { + if (isset($_REQUEST['__path__']) && strlen($_REQUEST['__path__'])) { return; } @@ -229,11 +229,21 @@ final class PhabricatorStartup { // Compatibility with PHP 5.4+ built-in web server. $url = parse_url($_SERVER['REQUEST_URI']); $_REQUEST['__path__'] = $url['path']; - } else { + return; + } + + if (!isset($_REQUEST['__path__'])) { self::didFatal( "Request parameter '__path__' is not set. Your rewrite rules ". "are not configured correctly."); } + + if (!strlen($_REQUEST['__path__'])) { + self::didFatal( + "Request parameter '__path__' is set, but empty. Your rewrite rules ". + "are not configured correctly. The '__path__' should always ". + "begin with a '/'."); + } }