From 2fd0e9fe5821522f96949fe88816677303df6929 Mon Sep 17 00:00:00 2001 From: skodak Date: Tue, 23 Sep 2008 21:09:46 +0000 Subject: [PATCH] MDL-16644 removing striplsahses() and friends --- calendar/event.php | 4 +-- lib/deprecatedlib.php | 8 +++++ lib/weblib.php | 79 ++---------------------------------------- mod/scorm/locallib.php | 2 +- 4 files changed, 14 insertions(+), 79 deletions(-) diff --git a/calendar/event.php b/calendar/event.php index a8a4bd2ca7..95ebc9b5e4 100644 --- a/calendar/event.php +++ b/calendar/event.php @@ -131,8 +131,8 @@ $form->name = clean_param(strip_tags($form->name,''), PARAM_CLEAN); // To avoid double slashes - $form->name = stripslashes($form->name); - $form->description = stripslashes($form->description); + $form->name = $form->name; + $form->description = $form->description; $form->timestart = make_timestamp($form->startyr, $form->startmon, $form->startday, $form->starthr, $form->startmin); if($form->duration == 1) { diff --git a/lib/deprecatedlib.php b/lib/deprecatedlib.php index a0d3062ab9..25c77d04bd 100644 --- a/lib/deprecatedlib.php +++ b/lib/deprecatedlib.php @@ -772,6 +772,14 @@ function rename_index($table, $index, $newname) { /// removed functions //// ////////////////////////// +function stripslashes_safe($mixed) { + error('stripslashes_safe() not available anymore'); +} + +function stripslashes_recursive($var) { + error('stripslashes_recursive() not available anymore'); +} + function addslashes_object($dataobject) { error('addslashes() not available anymore'); } diff --git a/lib/weblib.php b/lib/weblib.php index 1cbaa0517e..656a382c98 100644 --- a/lib/weblib.php +++ b/lib/weblib.php @@ -125,7 +125,7 @@ function s($var, $strip=false) { } if ($strip) { - return preg_replace("/&(#\d+);/i", "&$1;", htmlspecialchars(stripslashes_safe($var))); + return preg_replace("/&(#\d+);/i", "&$1;", htmlspecialchars($var)); } else { return preg_replace("/&(#\d+);/i", "&$1;", htmlspecialchars($var)); } @@ -472,79 +472,6 @@ function data_submitted() { } } -/** - * Moodle replacement for php stripslashes() function, - * works also for objects and arrays. - * - * The standard php stripslashes() removes ALL backslashes - * even from strings - so C:\temp becomes C:temp - this isn't good. - * This function should work as a fairly safe replacement - * to be called on quoted AND unquoted strings (to be sure) - * - * @param mixed something to remove unsafe slashes from - * @return mixed - */ -function stripslashes_safe($mixed) { - // there is no need to remove slashes from int, float and bool types - if (empty($mixed)) { - //nothing to do... - } else if (is_string($mixed)) { - if (ini_get_bool('magic_quotes_sybase')) { //only unescape single quotes - $mixed = str_replace("''", "'", $mixed); - } else { //the rest, simple and double quotes and backslashes - $mixed = str_replace("\\'", "'", $mixed); - $mixed = str_replace('\\"', '"', $mixed); - $mixed = str_replace('\\\\', '\\', $mixed); - } - } else if (is_array($mixed)) { - foreach ($mixed as $key => $value) { - $mixed[$key] = stripslashes_safe($value); - } - } else if (is_object($mixed)) { - $vars = get_object_vars($mixed); - foreach ($vars as $key => $value) { - $mixed->$key = stripslashes_safe($value); - } - } - - return $mixed; -} - -/** - * Recursive implementation of stripslashes() - * - * This function will allow you to strip the slashes from a variable. - * If the variable is an array or object, slashes will be stripped - * from the items (or properties) it contains, even if they are arrays - * or objects themselves. - * - * @param mixed the variable to remove slashes from - * @return mixed - */ -function stripslashes_recursive($var) { - if (is_object($var)) { - $new_var = new object(); - $properties = get_object_vars($var); - foreach($properties as $property => $value) { - $new_var->$property = stripslashes_recursive($value); - } - - } else if(is_array($var)) { - $new_var = array(); - foreach($var as $property => $value) { - $new_var[$property] = stripslashes_recursive($value); - } - - } else if(is_string($var)) { - $new_var = stripslashes($var); - - } else { - $new_var = $var; - } - - return $new_var; -} - /** * Given some normal text this function will break up any * long words to a given size by inserting the given character @@ -3908,9 +3835,9 @@ function print_heading($text, $align='', $size=2, $class='main', $return=false, $id = ' id="'.$id.'"'; } if (!defined('CLI_UPGRADE') || !CLI_UPGRADE ) { - $output = "".stripslashes_safe($text).""; + $output = "".$text.""; } else if ( CLI_UPGRADE ) { - $output = stripslashes_safe($text); + $output = $text; if ($size == 1) { $output = '=>'.$output; } else if ($size == 2) { diff --git a/mod/scorm/locallib.php b/mod/scorm/locallib.php index c4e36ae478..ae3d0d641d 100755 --- a/mod/scorm/locallib.php +++ b/mod/scorm/locallib.php @@ -228,7 +228,7 @@ function scorm_get_scoes($id,$organisation=false) { foreach ($scoes as $sco) { if ($scodatas = $DB->get_records('scorm_scoes_data',array('scoid'=>$sco->id))) { foreach ($scodatas as $scodata) { - $sco->{$scodata->name} = stripslashes_safe($scodata->value); + $sco->{$scodata->name} = $scodata->value; } } } -- 2.39.5