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

Add maxlength rule in moodle form doesn't support utf8

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Critical
    • Resolution: Fixed
    • Affects Version/s: 2.4, 2.4.6, 2.5.2
    • Fix Version/s: 2.4.7, 2.5.3, 2.6
    • Component/s: Forms Library
    • Labels:
    • Testing Instructions:
      Hide

      1/ Run phpunit tests on all branches
      2/ Upload the attached test.php to your moodle, and run it in the browser.
      3/ Fill our the form fields (in order)

      A: 日本語語
      B: 日本語語
      C: 日本語
      D: 日本語
      

      4/ VERIFY: you get a JS warning about A and C
      5/ Change the fields with warnings to:

      A: 日本語
      C: 日本語語
      

      6/ VERIFY: the JS warnings go away
      7/ Submit the form
      8/ VERIFY: warnings about B and D are seen
      9/ VERIFY: 'null' is displayed at the top
      10/ Change the fields with warnigns to:

      B: 日本語
      D: 日本語日
      

      11/ Submit the form
      12/ VERIFY: the form submits
      13/ VERIFY: you see a var_dump of all the expected data

      Show
      1/ Run phpunit tests on all branches 2/ Upload the attached test.php to your moodle, and run it in the browser. 3/ Fill our the form fields (in order) A: 日本語語 B: 日本語語 C: 日本語 D: 日本語 4/ VERIFY: you get a JS warning about A and C 5/ Change the fields with warnings to: A: 日本語 C: 日本語語 6/ VERIFY: the JS warnings go away 7/ Submit the form 8/ VERIFY: warnings about B and D are seen 9/ VERIFY: 'null' is displayed at the top 10/ Change the fields with warnigns to: B: 日本語 D: 日本語日 11/ Submit the form 12/ VERIFY: the form submits 13/ VERIFY: you see a var_dump of all the expected data
    • Affected Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE
    • Fixed Branches:
      MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • Pull Master Branch:
      MDL-40267-master

      Description

      When using maxlength rule on moodle form with utf8 lang
      you can actually add half of the chars in the rule for example in most of the activities mod_form
      the name max length is 255 but in utf8 you can add only 127 chars

      $mform->addRule('name', get_string('maximumchars', '', 255), 'maxlength', 255, 'client');

      It's happened because pear HTML_QuickForm Rule_Range class use strlen instead of using mb_strlen and encoding format

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

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

                  Dates

                  • Created:
                    Updated:
                    Resolved:
                    Fix Release Date:
                    11/Nov/13