mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/15742] Remove addslashes_recursively()
PHPBB3-15742
This commit is contained in:
parent
8eb48e2812
commit
89d1401a77
3 changed files with 0 additions and 45 deletions
|
@ -18,34 +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
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* 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]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Set variable $result to a particular type.
|
* Set variable $result to a particular type.
|
||||||
*
|
*
|
||||||
|
|
|
@ -18,13 +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);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 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