Non-core contributed modules

Journal feedback report not stripping slashes

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Minor Minor
  • Resolution: Fixed
  • Affects Version/s: 1.9.8
  • Fix Version/s: None
  • Component/s: Module: Journal
  • Labels:
  • URL:
    http://<moodle url>/mod/journal/report.php
  • Affected Branches:
    MOODLE_19_STABLE

Description

Journal Feedback Report page http://<moodle url>/mod/journal/report.php correctly saves entries with apostrophes & double quotes slash-escaped, but does not remove the slashes before dispalying when showing user entries.

E.g. can't shows up as can\'t

One possible fix is to add stripslashes to "p($entry->entrycomment);" like this:

function journal_print_user_entry($course, $user, $entry, $teachers, $grades) {
...
...
if ($entry->timemarked) { echo "  <font size=\"1\">".userdate($entry->timemarked)."</font>"; }
echo "<br /><textarea name=\"c$entry->id\" rows=\"12\" cols=\"60\" wrap=\"virtual\">";
p(stripslashes($entry->entrycomment));
echo "</textarea><br />";
echo "</td></tr>";
}
echo "</table><br clear=\"all\" />\n";
}

Issue Links

Activity

Hide
Chris Potter added a comment -

I would say that this "should" fix the issue, but it doesn't completely. If you don't update all of the feedback at once, then the next time you go to edit it, the slashes get slashed, meaning for each subsequent save, more slashes appear in the feedback area. Seems to me this is because addslashes is getting done every time and should check to see if it's necessary before adding more.

Anyone disagree? Mark, I assume it's just you and me on this one. Thanks.

Show
Chris Potter added a comment - I would say that this "should" fix the issue, but it doesn't completely. If you don't update all of the feedback at once, then the next time you go to edit it, the slashes get slashed, meaning for each subsequent save, more slashes appear in the feedback area. Seems to me this is because addslashes is getting done every time and should check to see if it's necessary before adding more. Anyone disagree? Mark, I assume it's just you and me on this one. Thanks.
Hide
Mark Webster added a comment -

You're right , Chris. We've given up on the Journal module entirely due to gradebook issues, moving to Online Assignment.

Show
Mark Webster added a comment - You're right , Chris. We've given up on the Journal module entirely due to gradebook issues, moving to Online Assignment.
Hide
Chris Potter added a comment -

Thanks fot getting back with me Mark. We will be doing the same soon. I just need to get the assignments converted.

Show
Chris Potter added a comment - Thanks fot getting back with me Mark. We will be doing the same soon. I just need to get the assignments converted.
Hide
Chris Follin added a comment -

We patched this on our sites with the attached patch. The idea is similar to the code in the description but we used stripslashes() at the point that $entrybyuser is updated in report.php rather than in journal_print_user_entry().

Show
Chris Follin added a comment - We patched this on our sites with the attached patch. The idea is similar to the code in the description but we used stripslashes() at the point that $entrybyuser is updated in report.php rather than in journal_print_user_entry().
Hide
Helen Foster added a comment -

Chris, thanks for your patch. You'll notice I've changed this from an MDL issue into a contrib issue as the Journal module is no longer included in the core Moodle.

Assigning to Journal component lead, David.

Show
Helen Foster added a comment - Chris, thanks for your patch. You'll notice I've changed this from an MDL issue into a contrib issue as the Journal module is no longer included in the core Moodle. Assigning to Journal component lead, David.
Hide
David Monllaó added a comment -

Hi,

Patch applied to contrib/mod/journal, thanks for report and patch! Chris (Potter), in order to remove the subsequent slashes you can replace:

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

for:

$entrybyuser[$entry->userid]->entrycomment = preg_replace("/\\\+('|\")/", "$1", $vals['c']);

I commit the attached patch version because preg_replace is slower than stripslashes

Show
David Monllaó added a comment - Hi, Patch applied to contrib/mod/journal, thanks for report and patch! Chris (Potter), in order to remove the subsequent slashes you can replace: $entrybyuser[$entry->userid]->entrycomment = stripslashes($vals['c']); for: $entrybyuser[$entry->userid]->entrycomment = preg_replace("/\\\+('|\")/", "$1", $vals['c']); I commit the attached patch version because preg_replace is slower than stripslashes

People

Vote (6)
Watch (8)

Dates

  • Created:
    Updated:
    Resolved: