From 522b9884c31d3f102711b0267630eda7cb02b0a6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20St=C3=B6ckel?= Date: Thu, 10 Jun 2010 12:36:27 +0000 Subject: [PATCH] Solved problem with magic_quotes_pgc and xajax request with depth greater 1 --- phpgwapi/inc/common_functions.inc.php | 19 +++++++++++++++++++ xajax.php | 15 ++++----------- 2 files changed, 23 insertions(+), 11 deletions(-) diff --git a/phpgwapi/inc/common_functions.inc.php b/phpgwapi/inc/common_functions.inc.php index 8e3d6265a0..6cf463aded 100755 --- a/phpgwapi/inc/common_functions.inc.php +++ b/phpgwapi/inc/common_functions.inc.php @@ -14,6 +14,25 @@ * @version $Id$ */ +/** +* applies stripslashes recursivly on each element of an array +* +* @param array &$var +* @return array +*/ +function array_stripslashes($var) +{ + if (!is_array($var)) + { + return stripslashes($var); + } + foreach($var as $key => $val) + { + $var[$key] = is_array($val) ? array_stripslashes($val) : stripslashes($val); + } + return $var; +} + /** * Return the number of bytes of a string, independent of mbstring.func_overload * AND the availability of mbstring diff --git a/xajax.php b/xajax.php index 86320b49aa..8aafe9890f 100644 --- a/xajax.php +++ b/xajax.php @@ -83,17 +83,6 @@ function doXMLHTTP() $argList = func_get_args(); $arg0 = array_shift($argList); - if(get_magic_quotes_gpc()) { - foreach($argList as $key => $value) { - if(is_array($value)) { - foreach($argList as $key1 => $value1) { - $argList[$key][$key1] = stripslashes($value1); - } - } else { - $argList[$key] = stripslashes($value); - } - } - } //error_log("xajax_doXMLHTTP('$arg0',...)".print_r($argList,true)); if (strpos($arg0,'::') !== false && strpos($arg0,'.') === false) // static method name app_something::method @@ -119,6 +108,10 @@ function doXMLHTTP() ); include('./header.inc.php'); + if(get_magic_quotes_gpc()) { + $argList = array_stripslashes($argList); + } + // now the header is included, we can set the charset $GLOBALS['xajax']->configure('characterEncoding',translation::charset()); define('XAJAX_DEFAULT_CHAR_ENCODING',translation::charset());