From 41c5347f9c7fc80491a3e2e7736bd48b9f70a9cb Mon Sep 17 00:00:00 2001 From: David Grudl Date: Wed, 20 May 2015 16:37:46 +0200 Subject: [PATCH] removed support for PHP < 5.4.1 --- readme.md | 2 +- src/Http/Helpers.php | 15 --------------- src/Http/RequestFactory.php | 8 -------- src/Http/Response.php | 12 +++--------- src/Http/Session.php | 4 +--- src/Http/Url.php | 6 ------ tests/Http/Session.SessionHandler.phpt | 1 - tests/Http/Session.handler-exceptions.phpt | 1 - tests/Http/Session.handler.phpt | 1 - 9 files changed, 5 insertions(+), 45 deletions(-) diff --git a/readme.md b/readme.md index 32a50a6a..6b255474 100644 --- a/readme.md +++ b/readme.md @@ -11,7 +11,7 @@ sanitization filter. HTTP Request ------------- -Nette cleans out data sent by user from control and invalid characters. It also removes any //magic_quotes//. +Nette cleans out data sent by user from control and invalid characters. The URL of the request is available as [api:Nette\Http\UrlScript] instance: diff --git a/src/Http/Helpers.php b/src/Http/Helpers.php index 25ea666d..7ec28012 100644 --- a/src/Http/Helpers.php +++ b/src/Http/Helpers.php @@ -79,19 +79,4 @@ public static function removeDuplicateCookies() } } - - /** - * @internal - */ - public static function stripSlashes($arr, $onlyKeys = FALSE) - { - $res = []; - foreach ($arr as $k => $v) { - $res[stripslashes($k)] = is_array($v) - ? self::stripSlashes($v, $onlyKeys) - : ($onlyKeys ? $v : stripslashes($v)); - } - return $res; - } - } diff --git a/src/Http/RequestFactory.php b/src/Http/RequestFactory.php index 18167796..4523e2d3 100644 --- a/src/Http/RequestFactory.php +++ b/src/Http/RequestFactory.php @@ -106,11 +106,6 @@ public function createHttpRequest() $post = $useFilter ? filter_input_array(INPUT_POST, FILTER_UNSAFE_RAW) : (empty($_POST) ? [] : $_POST); $cookies = $useFilter ? filter_input_array(INPUT_COOKIE, FILTER_UNSAFE_RAW) : (empty($_COOKIE) ? [] : $_COOKIE); - if (get_magic_quotes_gpc()) { - $post = Helpers::stripslashes($post, $useFilter); - $cookies = Helpers::stripslashes($cookies, $useFilter); - } - // remove invalid characters $reChars = '#^[' . self::CHARS . ']*+\z#u'; if (!$this->binary) { @@ -152,9 +147,6 @@ public function createHttpRequest() continue; } elseif (!is_array($v['name'])) { - if (get_magic_quotes_gpc()) { - $v['name'] = stripSlashes($v['name']); - } if (!$this->binary && (!preg_match($reChars, $v['name']) || preg_last_error())) { $v['name'] = ''; } diff --git a/src/Http/Response.php b/src/Http/Response.php index 401fd2bf..9e0c1baf 100644 --- a/src/Http/Response.php +++ b/src/Http/Response.php @@ -46,16 +46,10 @@ class Response extends Nette\Object implements IResponse public function __construct() { - if (PHP_VERSION_ID >= 50400) { - if (is_int($code = http_response_code())) { - $this->code = $code; - } - } - - if (PHP_VERSION_ID >= 50401) { // PHP bug #61106 - $rm = new \ReflectionMethod('Nette\Http\Helpers::removeDuplicateCookies'); - header_register_callback($rm->getClosure()); // requires closure due PHP bug #66375 + if (is_int($code = http_response_code())) { + $this->code = $code; } + header_register_callback((new \ReflectionMethod('Nette\Http\Helpers::removeDuplicateCookies'))->getClosure()); // requires closure due PHP bug #66375 } diff --git a/src/Http/Session.php b/src/Http/Session.php index a7792f78..eb3dc83d 100644 --- a/src/Http/Session.php +++ b/src/Http/Session.php @@ -102,7 +102,6 @@ public function start() } catch (\Exception $e) { } - Helpers::removeDuplicateCookies(); if ($e) { @session_write_close(); // this is needed throw $e; @@ -232,7 +231,6 @@ public function regenerateId() $backup = $_SESSION; session_start(); $_SESSION = $backup; - Helpers::removeDuplicateCookies(); } $this->regenerated = TRUE; } @@ -509,7 +507,7 @@ public function setSavePath($path) /** - * Sets user session storage for PHP < 5.4. For PHP >= 5.4, use setHandler(). + * @deprecated use setHandler(). * @return self */ public function setStorage(ISessionStorage $storage) diff --git a/src/Http/Url.php b/src/Http/Url.php index 8bfbda1d..a4c74f11 100644 --- a/src/Http/Url.php +++ b/src/Http/Url.php @@ -282,9 +282,6 @@ public function appendQuery($value) */ public function getQuery() { - if (PHP_VERSION_ID < 50400) { - return str_replace('+', '%20', http_build_query($this->query, '', '&')); - } return http_build_query($this->query, '', '&', PHP_QUERY_RFC3986); } @@ -492,9 +489,6 @@ function($m) { return '%25' . strtoupper($m[1]); }, public static function parseQuery($s) { parse_str($s, $res); - if (get_magic_quotes_gpc()) { // for PHP 5.3 - $res = Helpers::stripSlashes($res); - } return $res; } diff --git a/tests/Http/Session.SessionHandler.phpt b/tests/Http/Session.SessionHandler.phpt index 3b67689d..154b0021 100644 --- a/tests/Http/Session.SessionHandler.phpt +++ b/tests/Http/Session.SessionHandler.phpt @@ -2,7 +2,6 @@ /** * Test: Nette\Http\Session storage. - * @phpversion 5.4 */ use Nette\Http\Session, diff --git a/tests/Http/Session.handler-exceptions.phpt b/tests/Http/Session.handler-exceptions.phpt index e73d76d3..3c8abc53 100644 --- a/tests/Http/Session.handler-exceptions.phpt +++ b/tests/Http/Session.handler-exceptions.phpt @@ -2,7 +2,6 @@ /** * Test: Nette\Http\Session handle storage exceptions. - * @phpversion 5.4 */ use Nette\Http, diff --git a/tests/Http/Session.handler.phpt b/tests/Http/Session.handler.phpt index 26fc2790..d7e2b41e 100644 --- a/tests/Http/Session.handler.phpt +++ b/tests/Http/Session.handler.phpt @@ -2,7 +2,6 @@ /** * Test: Nette\Http\Session storage. - * @phpversion 5.4 */ use Nette\Object,