-
Bug
-
Resolution: Fixed
-
Minor
-
None
-
3.5.11, 3.6.9, 3.7.5, 3.8.2, 3.9
-
None
-
MOODLE_35_STABLE, MOODLE_36_STABLE, MOODLE_37_STABLE, MOODLE_38_STABLE, MOODLE_39_STABLE
Right now our (old, version 2.x) phpcs defaults to 'iso-8859-1' as file encoding. And all out files are 'utf-8' encoded.
Normally (99% of times), that's not a problem, because 1-byte (ascii, english) chars are the same and we rarely need multibyte chars in source code.
But there are cases like this (real one, part of a unit test):
list($status, $notice, $url) = core_login_process_password_reset(null, 'pŘÍLIŠžLuŤOuČkÝkŮŇúPĚLďÁLEBSKÉóDY@eXaMpLe.CoM');
|
Where counting chars as iso leads to wrong results. 143 chars (bytes) are counted, instead of the correct 128 (utf-8) chars the line has.
And that's reported by the codechecker with warning:
Line exceeds 132 characters; contains 143 characters (moodle.Files.LineLength.TooLong)
|
Also, similarly, we have another "char counter" (away from phpcs) for files not being php/js/css that is also using strlen() to count bytes:
https://github.com/moodlehq/moodle-local_codechecker/blob/master/locallib.php#L410-L416
This issue is about to pass/setup the correct --encoding=utf-8 to our CodeSniffer.php / CodeSniffer/CLI.php, that magically will fix the example line above.
And also change the found strlen() uses found in custom checks by utf-8 savy alternatives.
Ciao
PS: Detected and shared by mudrd8mz, thanks!
- Discovered while testing
-
MDL-68183 Searching for user by email (case-insensitive + accent-sensitive) is too expensive on MySQL with many users
- Closed