From 53a832fd90e5c2e760295611c8b9ebd425de32f3 Mon Sep 17 00:00:00 2001 From: Steve Clay Date: Tue, 29 Sep 2015 15:59:02 -0400 Subject: [PATCH] Be clearer about missing params Fixes #423 --- index.php | 5 +++-- lib/Minify.php | 14 ++++++++++---- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index e001a7e..1d9abc4 100644 --- a/index.php +++ b/index.php @@ -107,9 +107,10 @@ $minify = call_user_func($min_factories['minify'], $cache); if (!$env->get('f') && $env->get('g') === null) { // no spec given + $msg = '

No "f" or "g" parameters were detected.

'; + $url = 'https://github.com/mrclay/minify/blob/master/docs/CommonProblems.wiki.md#long-url-parameters-are-ignored'; $defaults = $minify->getDefaultOptions(); - $url = 'https://github.com/mrclay/minify/blob/master/docs/UserGuide.wiki.md#creating-minify-urls'; - $minify->errorExit($defaults['badRequestHeader'], $url); + $minify->errorExit($defaults['badRequestHeader'], $url, $msg); } $sourceFactoryOptions = array(); diff --git a/lib/Minify.php b/lib/Minify.php index 4c4db8f..9b208e3 100644 --- a/lib/Minify.php +++ b/lib/Minify.php @@ -428,14 +428,15 @@ class Minify { /** * Show an error page * - * @param string $header E.g. 'HTTP/1.0 500 Internal Server Error' - * @param string $url URL to direct the user to + * @param string $header Full header. E.g. 'HTTP/1.0 500 Internal Server Error' + * @param string $url URL to direct the user to + * @param string $msgHtml HTML message for the client * * @return void * @internal This is not part of the public API and is subject to change * @access private */ - public function errorExit($header, $url) + public function errorExit($header, $url = '', $msgHtml = '') { $url = htmlspecialchars($url, ENT_QUOTES); list(,$h1) = explode(' ', $header, 2); @@ -445,7 +446,12 @@ class Minify { header($header, true, $code); header('Content-Type: text/html; charset=utf-8'); echo "

$h1

"; - echo "

Please see $url.

"; + if ($msgHtml) { + echo $msgHtml; + } + if ($url) { + echo "

Please see $url.

"; + } exit; }