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

Add maxlength rule in moodle form doesn't support utf8

XMLWordPrintable

    • MOODLE_24_STABLE, MOODLE_25_STABLE
    • MOODLE_24_STABLE, MOODLE_25_STABLE, MOODLE_26_STABLE
    • MDL-40267-master
    • 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

      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

        1. test.php
          1 kB
          Dan Poltawski

            poltawski Dan Poltawski
            rafieliasaf Rafi Eliasaf
            Petr Skoda Petr Skoda
            Marina Glancy Marina Glancy
            Michael de Raadt Michael de Raadt
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                Error rendering 'clockify-timesheets-time-tracking-reports:timer-sidebar'. Please contact your Jira administrators.