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

Algebra filter is triggered also by Unified Diff change chunkes

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Trivial
    • Resolution: Fixed
    • Affects Version/s: 1.9
    • Fix Version/s: 2.2.5, 2.3.2
    • Component/s: Filters
    • Labels:
      None
    • Environment:
      Any
    • Database:
      Any
    • Difficulty:
      Easy
    • Affected Branches:
      MOODLE_19_STABLE
    • Fixed Branches:
      MOODLE_22_STABLE, MOODLE_23_STABLE

      Description

      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

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              salvetore Michael de Raadt added a comment -

              Thanks for reporting this issue.

              We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported.

              If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed.

              Michael d;

              lqjjLKA0p6

              Show
              salvetore Michael de Raadt added a comment - Thanks for reporting this issue. We have detected that this issue has been inactive for over a year has been recorded as affecting versions that are no longer supported. If you believe that this issue is still relevant to current versions (2.1 and beyond), please comment on the issue. Issues left inactive for a further month will be closed. Michael d; lqjjLKA0p6
              Hide
              matteo Matteo Scaramuccia added a comment -

              Hi Michael,
              pretty sure that this is an issue, even if MINOR but easily fixable (see my patch proposal).
              If of any interest, I can provide in the next weeks a git branch for my patch.

              Matteo

              Show
              matteo Matteo Scaramuccia added a comment - Hi Michael, pretty sure that this is an issue, even if MINOR but easily fixable (see my patch proposal). If of any interest, I can provide in the next weeks a git branch for my patch. Matteo
              Hide
              timhunt Tim Hunt added a comment -

              I am planning to fix this at the same time as MDL-31244.

              Show
              timhunt Tim Hunt added a comment - I am planning to fix this at the same time as MDL-31244 .
              Hide
              matteo Matteo Scaramuccia added a comment -

              TNX!

              Show
              matteo Matteo Scaramuccia added a comment - TNX!
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Closing this as fixed (by MDL-31244). Thanks!

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Closing this as fixed (by MDL-31244 ). Thanks!

                People

                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    10/Sep/12