]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-16644 removing striplsahses() and friends
authorskodak <skodak>
Tue, 23 Sep 2008 21:09:46 +0000 (21:09 +0000)
committerskodak <skodak>
Tue, 23 Sep 2008 21:09:46 +0000 (21:09 +0000)
calendar/event.php
lib/deprecatedlib.php
lib/weblib.php
mod/scorm/locallib.php

index a8a4bd2ca75dac691a5c1f6f2aa5bd76f7e24563..95ebc9b5e4985656f54b5572a298c3a179401495 100644 (file)
                 $form->name = clean_param(strip_tags($form->name,'<lang><span>'), 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) {
index a0d3062ab9f85d6d5f6f4edbdfafc173ba591311..25c77d04bdd4907f8e0107bfc3a8e3072f0403b7 100644 (file)
@@ -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');
 }
index 1cbaa0517e4ea821955fc323fc5c5f71406b8340..656a382c98902a1667e840b99651e8482389e85e 100644 (file)
@@ -125,7 +125,7 @@ function s($var, $strip=false) {
     }
 
     if ($strip) {
-        return preg_replace("/&amp;(#\d+);/i", "&$1;", htmlspecialchars(stripslashes_safe($var)));
+        return preg_replace("/&amp;(#\d+);/i", "&$1;", htmlspecialchars($var));
     } else {
         return preg_replace("/&amp;(#\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 = "<h$size $align $class $id>".stripslashes_safe($text)."</h$size>";
+    $output = "<h$size $align $class $id>".$text."</h$size>";
     } else if ( CLI_UPGRADE ) {
-        $output = stripslashes_safe($text);
+        $output = $text;
         if ($size == 1) {
             $output = '=>'.$output;
         } else if ($size == 2) {
index c4e36ae47830c4018556baa9e1538d45de75dc48..ae3d0d641de421c0f217a1e6eaf39c35f66ba0ef 100755 (executable)
@@ -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;
                 }
             }
         }