Skip to content

Commit

Permalink
removed support for PHP < 5.4.1
Browse files Browse the repository at this point in the history
  • Loading branch information
dg committed May 20, 2015
1 parent 926df8e commit 41c5347
Show file tree
Hide file tree
Showing 9 changed files with 5 additions and 45 deletions.
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -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:

Expand Down
15 changes: 0 additions & 15 deletions src/Http/Helpers.php
Expand Up @@ -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;
}

}
8 changes: 0 additions & 8 deletions src/Http/RequestFactory.php
Expand Up @@ -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) {
Expand Down Expand Up @@ -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'] = '';
}
Expand Down
12 changes: 3 additions & 9 deletions src/Http/Response.php
Expand Up @@ -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
}


Expand Down
4 changes: 1 addition & 3 deletions src/Http/Session.php
Expand Up @@ -102,7 +102,6 @@ public function start()
} catch (\Exception $e) {
}

Helpers::removeDuplicateCookies();
if ($e) {
@session_write_close(); // this is needed
throw $e;
Expand Down Expand Up @@ -232,7 +231,6 @@ public function regenerateId()
$backup = $_SESSION;
session_start();
$_SESSION = $backup;
Helpers::removeDuplicateCookies();
}
$this->regenerated = TRUE;
}
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 0 additions & 6 deletions src/Http/Url.php
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
}

Expand Down
1 change: 0 additions & 1 deletion tests/Http/Session.SessionHandler.phpt
Expand Up @@ -2,7 +2,6 @@

/**
* Test: Nette\Http\Session storage.
* @phpversion 5.4
*/

use Nette\Http\Session,
Expand Down
1 change: 0 additions & 1 deletion tests/Http/Session.handler-exceptions.phpt
Expand Up @@ -2,7 +2,6 @@

/**
* Test: Nette\Http\Session handle storage exceptions.
* @phpversion 5.4
*/

use Nette\Http,
Expand Down
1 change: 0 additions & 1 deletion tests/Http/Session.handler.phpt
Expand Up @@ -2,7 +2,6 @@

/**
* Test: Nette\Http\Session storage.
* @phpversion 5.4
*/

use Nette\Object,
Expand Down

0 comments on commit 41c5347

Please sign in to comment.