From 13ca56cf52513aedbe1c42ecaa2ffad2c0d4741c Mon Sep 17 00:00:00 2001 From: stronk7 Date: Fri, 27 Jan 2006 23:01:34 +0000 Subject: [PATCH] Solving double addslashes to DB when the site is running with magic_quotes_gpc() disabled (because Moodle addslashes to everything). Not a pretty hack, but it seems to work. (http://moodle.org/mod/forum/discuss.php?d=38127) Merged from MOODLE_15_STABLE --- .../ewiki/fragments/strip_wonderful_slashes.php | 13 ++++++++----- mod/wiki/view.php | 10 ++++++---- 2 files changed, 14 insertions(+), 9 deletions(-) diff --git a/mod/wiki/ewiki/fragments/strip_wonderful_slashes.php b/mod/wiki/ewiki/fragments/strip_wonderful_slashes.php index ca858c44ea7..261134848e3 100644 --- a/mod/wiki/ewiki/fragments/strip_wonderful_slashes.php +++ b/mod/wiki/ewiki/fragments/strip_wonderful_slashes.php @@ -20,9 +20,13 @@ #-- this is very evil too set_magic_quotes_runtime(0); - - #-- strip \'s only if the variables garbaging is really enabled - if (get_magic_quotes_gpc()) { + #-- Moodle always addslashes to everything so + #-- we strip them back again here to allow + #-- the wiki module itself to add them before + #-- insert. Strange triple add-strip-add but + #-- this was the best way to solve problems + #-- without changing how the rest of the + #-- module works. $superglobals = array( "_REQUEST", @@ -43,7 +47,6 @@ } } - } -?> \ No newline at end of file +?> diff --git a/mod/wiki/view.php b/mod/wiki/view.php index 3eb08bdba3d..b21f68ca894 100644 --- a/mod/wiki/view.php +++ b/mod/wiki/view.php @@ -111,10 +111,12 @@ define("EWIKI_INIT_PAGES", wiki_content_dir($wiki)); -/// # fix broken PHP setup - if (!function_exists("get_magic_quotes_gpc") || get_magic_quotes_gpc()) { - include($CFG->dirroot."/mod/wiki/ewiki/fragments/strip_wonderful_slashes.php"); - } +/// # Moodle always addslashes to everything so we are going to strip them always +/// # to allow wiki itself to add them again. It's a triple add-strip-add but +/// # was the only way to solve the problem without modifying how the rest of +/// # the module works. + include($CFG->dirroot."/mod/wiki/ewiki/fragments/strip_wonderful_slashes.php"); + if (ini_get("register_globals")) { # include($CFG->dirroot."/mod/wiki/ewiki/fragments/strike_register_globals.php"); }