Uploaded image for project: 'Moodle'
  1. Moodle
  2. MDL-25063

Algebra filter is triggered also by Unified Diff change chunkes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Trivial Trivial
    • 2.2.5, 2.3.2
    • 1.9
    • Filters
    • None
    • Any
    • Any
    • MOODLE_19_STABLE
    • MOODLE_22_STABLE, MOODLE_23_STABLE
    • Easy

      Having added a diff -u output in a post on moodle.org I've fallen into this issue, better described in MDLSITE-1113.

      It appears the algebra filter allows a user to escape a "@@...@@" sequence by prepending an extra "@": since Unified Diff is a well-known format and users cannot edit this output before posting it in Moodle Community, the patch below will escape such sequences without the need of an extra prepended "@":

      --- algebra\filter.php.orig	Thu Nov 04 10:52:20 2010
      +++ algebra\filter.php	Thu Nov 04 10:51:53 2010
      @@ -114,10 +114,18 @@
       
           $text .= ' ';
       
      +    // Prepending @ to a @@..@... sequence avoid any conversion
           preg_match_all('/@(@@+)([^@])/',$text,$matches);
           for ($i=0;$i<count($matches[0]);$i++) {
               $replacement = str_replace('@','&#x00040;',$matches[1][$i]).$matches[2][$i];
               $text = str_replace($matches[0][$i],$replacement,$text);
      +    }
      +
      +    // Escape @@...@@ occurences when representing Unified Diff change chunkes
      +    preg_match_all('/@@ \-(\d+(,\d+)?) \+(\d+(,\d+)?) @@/',$text,$matches);
      +    for ($i=0; $i < count($matches[0]); $i++) {
      +        $replacement = str_replace('@', '&#x00040;', $matches[0][$i]);
      +        $text = str_replace($matches[0][$i], $replacement, $text);
           }
       
           // <algebra> some algebraic input expression </algebra>

      The same applies to HEAD branch.

      Matteo

            timhunt Tim Hunt
            matteo Matteo Scaramuccia
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.