[dokuwiki] Re: quotation marks always goes escaped

  • From: "Arthit Suriyawongkul" <arthit@xxxxxxxxx>
  • To: dokuwiki@xxxxxxxxxxxxx
  • Date: Wed, 7 Nov 2007 21:41:30 +0700

On 07/11/2007, Andreas Gohr <andi@xxxxxxxxxxxxxx> wrote:
> Arthit Suriyawongkul writes:
> > On 07/11/2007, Arthit Suriyawongkul <arthit@xxxxxxxxx> wrote:
> >> whenever I type " or ' in my dokuwiki ( http://cc.in.th/wiki/ )
> >> it will always be converted to \" and \' when I save the page.
> > I also installed a modified version of Mark Cunningham's WordPress
> > authentication.
> > in the code, there're few lines that call
> > remove_magic_quotes( ) for $GET, $POST, and several vars.
>
> Yes. Both systems, DokuWiki and WordPress handle the stupid MagicQuote
> setting resulting in double encoding. Simply disabling magic quotes in your
> PHP config should fix the problem

unfortunately, I use a shared hosting service. And thus can't change
the php.ini.

so i decided to change this code (in inc/auth/wordpress.class.php):

    // kill magic quotes... again!
    if (get_magic_quotes_gpc()) {
      if (!empty($_GET))    remove_magic_quotes($_GET);
      if (!empty($_POST))   remove_magic_quotes($_POST);
      if (!empty($_COOKIE)) remove_magic_quotes($_COOKIE);
      if (!empty($_REQUEST)) remove_magic_quotes($_REQUEST);
      if (!empty($_SESSION)) remove_magic_quotes($_SESSION); #FIXME needed ?
      @ini_set('magic_quotes_gpc', 0);
    }
    @set_magic_quotes_runtime(0);
    @ini_set('magic_quotes_sybase',0);

to:

    // kill magic quotes... again!
    if (!empty($_GET))    remove_magic_quotes($_GET);
    if (!empty($_POST))   remove_magic_quotes($_POST);
    if (!empty($_COOKIE)) remove_magic_quotes($_COOKIE);
    if (!empty($_REQUEST)) remove_magic_quotes($_REQUEST);
    if (!empty($_SESSION)) remove_magic_quotes($_SESSION); #FIXME needed ?
    @ini_set('magic_quotes_gpc', 0);
    @set_magic_quotes_runtime(0);
    @ini_set('magic_quotes_sybase',0);

(just removing if condition, to force it remove_magic_quotes() everytime)

i've tested it, and it works ok.
the quotes are no longer get escaped anymore.

but i worried if this will has side effects, like security ones, what
do you think ?

cheers,
Art

(thanks again for your answer in previous mail :) )

-- 
:: "เอกราช ปลอดภัย เศรษฐกิจ
::  เสมอภาค เสรีภาพ การศึกษา"
:: -- หลัก 6 ประการของคณะราษฎร
:: http://tinyurl.com/34klvq

Other related posts: