[pmwiki-users] bug in commentbox

Patrick R. Michaud pmichaud at pobox.com
Thu Mar 23 09:12:19 CST 2006


On Thu, Mar 23, 2006 at 12:04:00PM +0000, Hans wrote:
> Thursday, March 23, 2006, 10:30:55 AM, Hans wrote:
> > Any idea how to prevent this?
> 
> I found one possible answer:
> Before the page text gets added to the post text
> all backslashes in th etext gets doubled, so later they can be
> stripped out again by HandleEdit srripmagic.
> 
> I added one line of code to achieve this:
> 
>  $page['text'] = str_replace("\\","\\\\",$page['text']);
> 
> Comments?

This will probably cause slashes to fail on systems that have
magic_quotes_gpc set to "off".

PmWiki's stripmagic() function is intended to deal with the
different settings of magic_quotes_gpc.  On systems where this
is set "On", PHP automatically adds backslashes in front of
various characters in input fields, but when it's turned off,
the backslashes aren't added.  Obviously PmWiki has to know if
extra slashes have been added, so stripmagic() takes them out
only if PHP has put them in.

So, if you always add backslashes to the text, stripmagic()
is likely to get it wrong when it thinks they weren't added.

I don't have a great answer for this (other than it's another
PHP brain-dead feature) -- for now I'd suggest adding the slashes
only if get_magic_quotes_gpc() returns true.

Pm




More information about the pmwiki-users mailing list