mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 12:28:52 +00:00
Merge pull request #5341 from senky/ticket/15742
[ticket/15742] Remove get_magic_quotes_gpc() call
This commit is contained in:
commit
13fe7b3ed2
4 changed files with 0 additions and 91 deletions
|
@ -150,8 +150,6 @@ class request implements \phpbb\request\request_interface
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->type_cast_helper->add_magic_quotes($value);
|
|
||||||
|
|
||||||
// setting to null means unsetting
|
// setting to null means unsetting
|
||||||
if ($value === null)
|
if ($value === null)
|
||||||
{
|
{
|
||||||
|
|
|
@ -18,69 +18,6 @@ namespace phpbb\request;
|
||||||
*/
|
*/
|
||||||
class type_cast_helper implements \phpbb\request\type_cast_helper_interface
|
class type_cast_helper implements \phpbb\request\type_cast_helper_interface
|
||||||
{
|
{
|
||||||
|
|
||||||
/**
|
|
||||||
* @var string Whether slashes need to be stripped from input
|
|
||||||
*/
|
|
||||||
protected $strip;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialises the type cast helper class.
|
|
||||||
* All it does is find out whether magic quotes are turned on.
|
|
||||||
*/
|
|
||||||
public function __construct()
|
|
||||||
{
|
|
||||||
if (version_compare(PHP_VERSION, '5.4.0-dev', '>='))
|
|
||||||
{
|
|
||||||
$this->strip = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
$this->strip = (@get_magic_quotes_gpc()) ? true : false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursively applies addslashes to a variable.
|
|
||||||
*
|
|
||||||
* @param mixed &$var Variable passed by reference to which slashes will be added.
|
|
||||||
*/
|
|
||||||
public function addslashes_recursively(&$var)
|
|
||||||
{
|
|
||||||
if (is_string($var))
|
|
||||||
{
|
|
||||||
$var = addslashes($var);
|
|
||||||
}
|
|
||||||
else if (is_array($var))
|
|
||||||
{
|
|
||||||
$var_copy = $var;
|
|
||||||
$var = array();
|
|
||||||
foreach ($var_copy as $key => $value)
|
|
||||||
{
|
|
||||||
if (is_string($key))
|
|
||||||
{
|
|
||||||
$key = addslashes($key);
|
|
||||||
}
|
|
||||||
$var[$key] = $value;
|
|
||||||
|
|
||||||
$this->addslashes_recursively($var[$key]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursively applies addslashes to a variable if magic quotes are turned on.
|
|
||||||
*
|
|
||||||
* @param mixed &$var Variable passed by reference to which slashes will be added.
|
|
||||||
*/
|
|
||||||
public function add_magic_quotes(&$var)
|
|
||||||
{
|
|
||||||
if ($this->strip)
|
|
||||||
{
|
|
||||||
$this->addslashes_recursively($var);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set variable $result to a particular type.
|
* Set variable $result to a particular type.
|
||||||
*
|
*
|
||||||
|
@ -129,8 +66,6 @@ class type_cast_helper implements \phpbb\request\type_cast_helper_interface
|
||||||
$result = preg_replace('/[\x80-\xFF]/', '?', $result);
|
$result = preg_replace('/[\x80-\xFF]/', '?', $result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$result = ($this->strip) ? stripslashes($result) : $result;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,20 +18,6 @@ namespace phpbb\request;
|
||||||
*/
|
*/
|
||||||
interface type_cast_helper_interface
|
interface type_cast_helper_interface
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Recursively applies addslashes to a variable.
|
|
||||||
*
|
|
||||||
* @param mixed &$var Variable passed by reference to which slashes will be added.
|
|
||||||
*/
|
|
||||||
public function addslashes_recursively(&$var);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Recursively applies addslashes to a variable if magic quotes are turned on.
|
|
||||||
*
|
|
||||||
* @param mixed &$var Variable passed by reference to which slashes will be added.
|
|
||||||
*/
|
|
||||||
public function add_magic_quotes(&$var);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set variable $result to a particular type.
|
* Set variable $result to a particular type.
|
||||||
*
|
*
|
||||||
|
|
|
@ -20,16 +20,6 @@ class phpbb_type_cast_helper_test extends phpbb_test_case
|
||||||
$this->type_cast_helper = new \phpbb\request\type_cast_helper();
|
$this->type_cast_helper = new \phpbb\request\type_cast_helper();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function test_addslashes_recursively()
|
|
||||||
{
|
|
||||||
$data = array('some"string' => array('that"' => 'really"', 'needs"' => '"escaping'));
|
|
||||||
$expected = array('some\\"string' => array('that\\"' => 'really\\"', 'needs\\"' => '\\"escaping'));
|
|
||||||
|
|
||||||
$this->type_cast_helper->addslashes_recursively($data);
|
|
||||||
|
|
||||||
$this->assertEquals($expected, $data);
|
|
||||||
}
|
|
||||||
|
|
||||||
public function test_simple_recursive_set_var()
|
public function test_simple_recursive_set_var()
|
||||||
{
|
{
|
||||||
$data = 'eviL<3';
|
$data = 'eviL<3';
|
||||||
|
|
Loading…
Add table
Reference in a new issue