Apostrophes and slashes

Apostrophes and slashes

by Bob Irving -
Number of replies: 5
I'm using Moodle 1.6.1
Red Hat Enterprise 9
Apache 2.2
PHP 5.1.x
MySQL 5.0

This happens ONLY in my responses in the Journal module:
1. I write a response and use a contraction.
2. I "save all feedback".
3. Apostrophe comes back with slash before apostrophe.
4. If I log out and log back in, the slash disappears.
5. I have to delete slashes from each post. When I re-save, one slash shows up. When I log out and log back in and view my posts, the slash is gone. If I don't manually remove the slashes, when I resave it adds more slashes in front of the apostrophe.
6. This only happens on MY replies in the Journal module, not in students' posts, or in any other module.

We have magic_quotes_gpc set to On,and magic_quotes_runtime set to Off.

Anybody have any ideas????

TIA,
Bob Irving
Average of ratings: -
In reply to Bob Irving

Re: Apostrophes and slashes

by Mark Penny -

Hopefully somebody with more experience and insight will take up the challenge here.

I've noticed that the slash before the apostrophe is essential in php to preserve the syntax. I imagine your problem is related. Slashes are being inserted to preserve syntax.

In reply to Mark Penny

Re: Apostrophes and slashes

by Bob Irving -
Thanks for the reply, Mark.

My theory is that it has to do with SQL, since you start enclose some statements with apostrophes. But it still doesn't explain the weird behaviour.

Bob
In reply to Bob Irving

Re: Apostrophes and slashes

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators

The use of single quotes (or apostrophes) and double quotes ("...") as syntax delimiters in programing languages has been a plague to making a normal usage of apostrophes and double quotes in normal text ever since the early days of programing.evil

However, there are workarounds, and here is a simple one for getting rid of those backslashes.

In Moodle 1.6+

In file \mod\journal\report.php, line 86 replace

                $entrybyuser[$entry->userid]->comment    = $vals['c'];

with

                $entrybyuser[$entry->userid]->comment    = stripslashes($vals['c']);

I've posted bug report MDL-6505

Joseph

In reply to Joseph Rézeau

Re: Apostrophes and slashes

by Joseph Rézeau -
Picture of Core developers Picture of Particularly helpful Moodlers Picture of Plugin developers Picture of Testers Picture of Translators
Hi Bob,
Did that help at all? Did you try it?
Joseph
In reply to Joseph Rézeau

Re: Apostrophes and slashes

by Bob Irving -
Hi Joseph and others.

First, thank you to those who responded. Your suggestion did fix the issue. Sorry I didn't post the resolution.

All the best, and many thanks again,
Bob