From 5bb5adcf9c769612eb61717cdaf97079d47df927 Mon Sep 17 00:00:00 2001 From: Taylor Otwell Date: Fri, 8 Jul 2011 12:38:54 -0700 Subject: [PATCH] Added Request::spoofed method. --- system/request.php | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/system/request.php b/system/request.php index 6cecf359..64b8b83c 100644 --- a/system/request.php +++ b/system/request.php @@ -69,14 +69,24 @@ private static function remove_from_uri($uri, $value) /** * Get the request method. * - * The request method may be spoofed if a hidden "REQUEST_METHOD" POST element - * is present, allowing HTML forms to simulate PUT and DELETE requests. - * * @return string */ public static function method() { - return (array_key_exists('REQUEST_METHOD', $_POST)) ? $_POST['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD']; + return (static::spoofed()) ? $_POST['REQUEST_METHOD'] : $_SERVER['REQUEST_METHOD']; + } + + /** + * Determine if the request method is being spoofed by a hidden Form element. + * + * Hidden form elements are used to spoof PUT and DELETE requests since + * they are not supported by HTML forms. + * + * @return bool + */ + public static function spoofed() + { + return array_key_exists('REQUEST_METHOD', $_POST); } /**