]> git.mjollnir.org Git - moodle.git/commitdiff
modify stripslashes_safe() to work properly under magic_quotes_sybase
authorstronk7 <stronk7>
Sun, 27 Aug 2006 21:52:22 +0000 (21:52 +0000)
committerstronk7 <stronk7>
Sun, 27 Aug 2006 21:52:22 +0000 (21:52 +0000)
(both addslashes and stripslashes do it properly based on the setting)

lib/weblib.php

index 249d22d0fa849cd2d88ec0d872a192148a66f959..921bb00bd906ecd92de843310e8e5328534f83d3 100644 (file)
@@ -358,9 +358,13 @@ function stripslashes_safe($mixed) {
     if (empty($mixed)) {
         //nothing to do...
     } else if (is_string($mixed)) {
-        $mixed = str_replace("\\'", "'", $mixed);
-        $mixed = str_replace('\\"', '"', $mixed);
-        $mixed = str_replace('\\\\', '\\', $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);