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

incorrect whitespace replacement breaks UTF8 in calendar import and tag cleaning

    XMLWordPrintable

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.7.7, 2.8.5
    • 2.7.8, 2.8.6
    • Calendar, Unit tests

    Description

      The trouble was discovered today by unit tests after moodle.org added Ukraine moot with borked UTF8 encoding.

      There was 1 failure:

      1) core_calendar_lib_testcase::test_calendar_cron_working_url
      Failed asserting that 'Updating calendar subscriptions:
      ... started 16:38:36. Current memory use 51.3MB.
      Updating calendar subscription test in course 1
      Error updating calendar subscription: Error writing to database (ERROR: invalid byte sequence for encoding "UTF8": 0xd1 0x20
      INSERT INTO phpmx_event (name,description,timestart,timeduration,uuid,timemodified,subscriptionid,userid,groupid,courseid,eventtype,format) VALUES($1,$2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12) RETURNING id
      [array (
      'name' => 'MoodleMoot Ukraine 2015',
      'description' => 'Теорія і практика використання системи управління навчанням Moo dleКиївський національний університет будівництва і ар? ітектури, 21-22 тра вня 2015 р.http://2015.moodlemoot.in.ua/ ',
      'timestart' => 1432191600,
      'timeduration' => 115200,
      'uuid' => '38598877@moodle.org',
      'timemodified' => 1427081918,
      'subscriptionid' => '1',
      'userid' => 0,
      'groupid' => '0',
      'courseid' => '1',
      'eventtype' => 'site',
      'format' => '1',
      )])
      Finished updating calendar subscriptions.
      ' matches PCRE pattern "/Events imported: .* Events updated:/".

      /Users/skodak/server/workspace/moodle/lib/phpunit/classes/advanced_testcase.php:80

      To re-run:
      vendor/bin/phpunit --colors core_calendar_lib_testcase calendar/tests/lib_test.php

      Solution is to use in calendar_add_icalendar_event()

      $description = preg_replace('/\s+/u', ' ', $description);

      instead of

      $description = preg_replace('/\s+/', ' ', $description);

      which breaks UTF-8

      Also the sloppy test should be fixed to use the exttests repository instead of live moodle.org server

      Attachments

        Issue Links

          Activity

            People

              skodak Petr Skoda
              skodak Petr Skoda
              Dan Poltawski Dan Poltawski
              Dan Poltawski Dan Poltawski
              David Woloszyn, Huong Nguyen, Jake Dallimore, Meirza, Michael Hawkins, Raquel Ortega, Safat Shahin, Stevani Andolo
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:
                11/May/15