Moodle

detect failed regexes duing multilang upgrade

Details

  • Type: Bug Bug
  • Status: Closed Closed
  • Priority: Major 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);

Activity

Hide
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
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
Penny Leach added a comment -

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

Show
Penny Leach added a comment - I should say, martin's fix ^^^ appears to solve both problems.
Hide
Petr Škoda (skodak) 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
Petr Škoda (skodak) 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
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
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
Petr Škoda (skodak) added a comment -

fixed in cvs

Show
Petr Škoda (skodak) added a comment - fixed in cvs
Hide
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
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
Penny Leach added a comment -

Reopening because of Pete Bulmer's comment

Show
Penny Leach added a comment - Reopening because of Pete Bulmer's comment
Hide
Petr Škoda (skodak) 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
Petr Škoda (skodak) 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

Vote (0)
Watch (2)

Dates

  • Created:
    Updated:
    Resolved: