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

preg_replace_callback range out of order in mod/url /locallib in PHP 5.2.x

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.0.6
    • Fix Version/s: 2.0.7
    • Component/s: Resource
    • Labels:
    • Testing Instructions:
      Hide

      1/ find server with php 5.2.x
      2/ try adding new url module instance

      Show
      1/ find server with php 5.2.x 2/ try adding new url module instance
    • Affected Branches:
      MOODLE_20_STABLE
    • Fixed Branches:
      MOODLE_20_STABLE
    • Pull from Repository:

      Description

      After upgrade to Moodle 2.0.6, mod/url des not opens up anymore the original location. With debugging, the following message is displayed:

      Warning: preg_replace_callback() [function.preg-replace-callback]: Compilation failed: range out of order in character class at offset 39 in /your/path/to/moodle/mod/url/locallib.php on line 95

      To reproduce:

      • on a 2.0.6 site, with Multimedia and Glossary filter on, turn debugging on
      • add an URL resource pointing to an external link.
      • configure the resource "view" option to "open" or "popup"
      • click "save and view". The Warning in displayed, the url is not open in the popup, and the link is not printed when resource "view" option is set to "open"

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

              Hide
              salvetore Michael de Raadt added a comment -

              This appears to duplicate the linked issue. Could you check your PHP version and see if this problem still exists?

              Show
              salvetore Michael de Raadt added a comment - This appears to duplicate the linked issue. Could you check your PHP version and see if this problem still exists?
              Hide
              andreabix Andrea Bicciolo added a comment -

              Michael,

              php version in the failing Moodle setups is 5.2.17, that should be OK as it is > 5.2.8.

              According to Server->Environment:

              php - version 5.2.8 is required and you are running 5.2.17.0.0 - OK

              And yes, the problem still exits.Please let me know if you want me give you some samples.

              Show
              andreabix Andrea Bicciolo added a comment - Michael, php version in the failing Moodle setups is 5.2.17, that should be OK as it is > 5.2.8. According to Server->Environment: php - version 5.2.8 is required and you are running 5.2.17.0.0 - OK And yes, the problem still exits.Please let me know if you want me give you some samples.
              Hide
              skodak Petr Skoda added a comment - - edited

              hello, I would need the exact URL that creates this problem.

              the error is somewhere in

              $allowed = "a-zA-Z0-9".preg_quote(';/?:@=&$_.+!*(),-#%', '/');
              $fullurl = preg_replace_callback("/[^$allowed]/", 'url_filter_callback', $fullurl);

              preg_quote() docs says that since 5.3 the - char is properly quoted, could you please try to move the - to the end of the string? that could help...

              $allowed = "a-zA-Z0-9".preg_quote(';/?:@=&$_.+!*(),#%-', '/');

              Show
              skodak Petr Skoda added a comment - - edited hello, I would need the exact URL that creates this problem. the error is somewhere in $allowed = "a-zA-Z0-9".preg_quote(';/?:@=&$_.+!*(),-#%', '/'); $fullurl = preg_replace_callback("/[^$allowed]/", 'url_filter_callback', $fullurl); preg_quote() docs says that since 5.3 the - char is properly quoted, could you please try to move the - to the end of the string? that could help... $allowed = "a-zA-Z0-9".preg_quote(';/?:@=&$_.+!*(),#%-', '/');
              Hide
              skodak Petr Skoda added a comment -

              In any case I would strongly recommend using PHP 5.3.x on all production servers especially for larger sites.

              Show
              skodak Petr Skoda added a comment - In any case I would strongly recommend using PHP 5.3.x on all production servers especially for larger sites.
              Hide
              andreabix Andrea Bicciolo added a comment -

              Hi Petr,

              sent you 3 samples of failing URLs.

              Show
              andreabix Andrea Bicciolo added a comment - Hi Petr, sent you 3 samples of failing URLs.
              Show
              skodak Petr Skoda added a comment - please try this: https://github.com/skodak/moodle/compare/MOODLE_20_STABLE...w50_MDL-30595_m20_regex
              Hide
              carco Rosario Carcò added a comment -

              Only for information, as Petr asked me to try the above patch: I have SUSE SLES 11 SP1, with: PHP version 5.2.8 is required and you are running 5.2.14

              Show
              carco Rosario Carcò added a comment - Only for information, as Petr asked me to try the above patch: I have SUSE SLES 11 SP1, with: PHP version 5.2.8 is required and you are running 5.2.14
              Hide
              skodak Petr Skoda added a comment -

              did it work?

              Show
              skodak Petr Skoda added a comment - did it work?
              Hide
              carco Rosario Carcò added a comment -

              OK, that patch works for me! Thanks a lot.

              Show
              carco Rosario Carcò added a comment - OK, that patch works for me! Thanks a lot.
              Hide
              skodak Petr Skoda added a comment -

              thanks for the testing!!

              Show
              skodak Petr Skoda added a comment - thanks for the testing!!
              Hide
              skodak Petr Skoda added a comment -

              to integrators: it is not necessary to change anything in 2.1 and above because it requries php 5.3 which quotes the - character in preg_quote()

              Show
              skodak Petr Skoda added a comment - to integrators: it is not necessary to change anything in 2.1 and above because it requries php 5.3 which quotes the - character in preg_quote()
              Hide
              andreabix Andrea Bicciolo added a comment -

              Hi Petr,
              tried your patch with the same sample URLs sent for your tests, and they worked.

              Show
              andreabix Andrea Bicciolo added a comment - Hi Petr, tried your patch with the same sample URLs sent for your tests, and they worked.
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Integrated, thanks!

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Integrated, thanks!
              Hide
              samhemelryk Sam Hemelryk added a comment -

              Passing testing as Andrea has previously tested this patch. Thanks Andrea!

              Show
              samhemelryk Sam Hemelryk added a comment - Passing testing as Andrea has previously tested this patch. Thanks Andrea!
              Hide
              stronk7 Eloy Lafuente (stronk7) added a comment -

              Yes, you did it!

              Now your code is part of the best weeklies released ever, many thanks!

              Closing, ciao

              Show
              stronk7 Eloy Lafuente (stronk7) added a comment - Yes, you did it! Now your code is part of the best weeklies released ever, many thanks! Closing, ciao

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    9/Jan/12