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

detect failed regexes duing multilang upgrade

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 1.8.1
    • Fix Version/s: 1.8.2, 1.9
    • Component/s: Filters
    • Labels:
      None
    • Affected Branches:
      MOODLE_18_STABLE
    • Fixed Branches:
      MOODLE_18_STABLE, MOODLE_19_STABLE

      Description

      (The same issue affects the multilang filter itself).

      This seemed to make it work:

      Index: multilangupgrade.php
      ===================================================================
      RCS file: /cvsroot/moodle/moodle/admin/multilangupgrade.php,v
      retrieving revision 1.4
      diff -c -r1.4 multilangupgrade.php

          • multilangupgrade.php 15 Jun 2007 06:08:51 -0000 1.4
          • multilangupgrade.php 18 Jun 2007 08:41:03 -0000
            ***************
          • 59,65 ****
            if ($rs and $rs->RecordCount() > 0) {
            while (!$rs->EOF) {
            $text = $rs->fields[$column];
            ! $search = '/(<(?:lang|span) lang="[a-zA-Z0-9_-]".?>.?<\/(?:lang|span)>)(\s*<(?:lang|span) lang="[a-zA-Z0-9_-]".?>.?<\/(?:lang|span)>)+/is';
            $newtext = preg_replace_callback($search, 'multilangupgrade_impl', $text);
            if ($newtext != $text) {
            $newtext = addslashes($newtext);
          • 59,65 ----
            if ($rs and $rs->RecordCount() > 0) {
            while (!$rs->EOF) {
            $text = $rs->fields[$column];
            ! $search = '/(<(?:lang|span) lang="[a-zA-Z0-9_-]".?>.+?<\/(?:lang|span)>)/is';
            $newtext = preg_replace_callback($search, 'multilangupgrade_impl', $text);
            if ($newtext != $text) {
            $newtext = addslashes($newtext);

        Gliffy Diagrams

          Activity

          Hide
          mjollnir Penny Leach added a comment -

          To reproduce the problem (using a simple example) - this should get modified and doesn't:

          http://pastebin.ca/573484

          To reproduce the problem (using a complicated example) - this should get modified but all data is lost:

          http://pastebin.ca/575006

          Show
          mjollnir Penny Leach added a comment - To reproduce the problem (using a simple example) - this should get modified and doesn't: http://pastebin.ca/573484 To reproduce the problem (using a complicated example) - this should get modified but all data is lost: http://pastebin.ca/575006
          Hide
          mjollnir Penny Leach added a comment -

          I should say, martin's fix ^^^ appears to solve both problems.

          Show
          mjollnir Penny Leach added a comment - I should say, martin's fix ^^^ appears to solve both problems.
          Hide
          skodak Petr Skoda added a comment -

          here is a patch that should solve it,
          please test it

          the multilang use is not correct in the sample text, the conversion will work only partially, but it should not "eat" the text anymore

          Show
          skodak Petr Skoda added a comment - here is a patch that should solve it, please test it the multilang use is not correct in the sample text, the conversion will work only partially, but it should not "eat" the text anymore
          Hide
          mjollnir Penny Leach added a comment -

          The patch works for me, at least it doesn't eat the text.

          I can't testify to its behaviour on valid blocks though.

          Show
          mjollnir Penny Leach added a comment - The patch works for me, at least it doesn't eat the text. I can't testify to its behaviour on valid blocks though.
          Hide
          skodak Petr Skoda added a comment -

          fixed in cvs

          Show
          skodak Petr Skoda added a comment - fixed in cvs
          Hide
          peterbulmer Peter Bulmer added a comment -

          I'm seeing an issue where parts the text are eaten - not the whole thing.

          The portion of text that goes missing ends mid-word, (aligned with a change in lang)

          The site in question has just been upgraded from 1.5 & is undergoing the multilang upgrade.

          For the full details, see
          http://paste.dollyfish.net.nz/618ed2
          becomes:
          http://paste.dollyfish.net.nz/baa9df

          Show
          peterbulmer Peter Bulmer added a comment - I'm seeing an issue where parts the text are eaten - not the whole thing. The portion of text that goes missing ends mid-word, (aligned with a change in lang) The site in question has just been upgraded from 1.5 & is undergoing the multilang upgrade. For the full details, see http://paste.dollyfish.net.nz/618ed2 becomes: http://paste.dollyfish.net.nz/baa9df
          Hide
          mjollnir Penny Leach added a comment -

          Reopening because of Pete Bulmer's comment

          Show
          mjollnir Penny Leach added a comment - Reopening because of Pete Bulmer's comment
          Hide
          skodak Petr Skoda added a comment -

          reclosing,
          sorry - nested spans are not supported, there must be only language specified (no extra css style) and the spans can not be nested.

          I hope we will change the multilang syntax after switching to some better htm leditor

          Show
          skodak Petr Skoda added a comment - reclosing, sorry - nested spans are not supported, there must be only language specified (no extra css style) and the spans can not be nested. I hope we will change the multilang syntax after switching to some better htm leditor

            People

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

              Dates

              • Created:
                Updated:
                Resolved:
                Fix Release Date:
                8/Jul/07