View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 16791 | Bug reports | Expression Manager | public | 2020-10-26 15:30 | 2026-10-14 20:29 |
| Reporter | Mazi | Assigned To | c_schmitz | ||
| Priority | normal | Severity | partial_block | ||
| Status | resolved | Resolution | fixed | ||
| Product Version | 3.24.3 | ||||
| Summary | 16791: strlen() function for counting characters has problems with special characters | ||||
| Description | The strlen() function acutally counts the byte size of a string, not the number of characters. Since special characters requires more bytes, counting characters using the EM strlen() function leads to wrong results, see attached screenshot or test this demo survey: https://ls300demo.survey-consulting.com/index.php/survey/index/sid/29488/newtest/Y/lang/en I recommend to NOT replace the strlen() function but keep it for backwards compatibility. Instead, can we add a new mb_strlen() function to EM (see https://www.php.net/manual/de/function.mb-strlen.php)? That should support correct counting of special characters. | ||||
| Steps To Reproduce | Import the attached survey. | ||||
| Additional Information | |||||
| Tags | No tags attached. | ||||
| Attached Files | |||||
| Bug heat | 14 | ||||
| Complete LimeSurvey version number (& build) | Version 3.24 | ||||
| I will donate to the project if issue is resolved | No | ||||
| Browser | Chrome | ||||
| Database type & version | MySQL 5 | ||||
| Server OS (if known) | Ubuntu 18 | ||||
| Webserver software & version (if known) | Apache | ||||
| PHP Version | 7.2.26 | ||||
|
@DenisChenu, you fixed a similar problem at the core code base a while ago: https://bugs.limesurvey.org/view.php?id=9785#c32724 |
|
|
multibyte strlen? |
|
|
2015-07-21 11:21 … yes a while ago … And seems i update strlmen to use mb_strlen : https://github.com/LimeSurvey/LimeSurvey/commit/c031c7d24d1fecf21dc970e8bccb38eb4abe0a9f#diff-a974f1aca3b64170e04f9ac415aadb10d9108696f0ae4ce07caee89d8a1447d3R2570 seems currently too : https://github.com/LimeSurvey/LimeSurvey/blob/70507e27f6d1886bb50d52d3833284450639c684/application/helpers/expressions/em_core_helper.php#L2678 |
|
|
<s>JS function need to be fixed/updated BUT</s> locutus/phpjs didn't have mb_strlen And the only fix seem : https://stackoverflow.com/questions/2482907/javascript-string-length-differs-from-php-mb-strlen :/ In act : js.length are already mb_strlen … |
|
|
Someone broke this in 3.X or 2.50x Working in 2.6lts : It's not the 1st time something broken in javascript expression … between 2.6lts and 2.5X |
|
|
Interesting that this worked before. So probably all we need to do is finding out which commit caused the problem and then revert to the previous code/function?! |
|
|
Surely in LEMval … |
|
|
https://github.com/LimeSurvey/LimeSurvey/blob/70507e27f6d1886bb50d52d3833284450639c684/assets/packages/expressions/em_javascript.js#L1169 |
|
|
Please check if this bug still exists in the latest patch release. Thank you. |
|
|
@ollehar, why don't you simply import the atteched test survey and test. That only takes a minute. I just did that and yes, this issue still exists, see https://ls3.my-survey.host/index.php/29488?newtest=Y&lang=en |
|
Classic Mazi. ^^ Because we have hundreds of tickets. It's more efficient if I spread out the testing. Obviously. |
|
Thanks! We'll look at this issue. |
|
|
Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=40863 |
|
|
LimeSurvey: master 63fd53a8 2026-10-14 20:29 Details Diff |
Fixed issue 16791: Character counts with strlen() were too high while typing when the answer contained umlauts or other accented characters Dev User entered values were encoded with htmlentities() in JavaScript (Ä became Ä), now htmlspecialchars() as in PHP; htmlentities() also double-encoded double quotes |
Affected Issues 16791 |
|
| mod - assets/packages/expressions/em_javascript.js | Diff File | ||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2020-10-26 15:30 | Mazi | New Issue | |
| 2020-10-26 15:30 | Mazi | File Added: image.png | |
| 2020-10-26 15:30 | Mazi | File Added: limesurvey_survey_29488.lss | |
| 2020-10-26 15:30 | Mazi | Note Added: 60414 | |
| 2020-10-26 15:30 | Mazi | Note Edited: 60414 | |
| 2020-10-26 17:17 | ollehar | Note Added: 60416 | |
| 2020-10-27 10:22 | DenisChenu | Note Added: 60417 | |
| 2020-10-27 10:28 | DenisChenu | Note Added: 60418 | |
| 2020-10-27 10:32 | DenisChenu | Note Added: 60419 | |
| 2020-10-27 10:32 | DenisChenu | File Added: Capture d’écran du 2020-10-27 10-31-25.png | |
| 2020-10-27 10:33 | DenisChenu | Note Edited: 60418 | |
| 2020-10-27 10:35 | Mazi | Note Added: 60420 | |
| 2020-10-27 10:36 | DenisChenu | Note Added: 60421 | |
| 2020-10-27 10:42 | DenisChenu | Note Added: 60422 | |
| 2021-03-03 16:00 | ollehar | Assigned To | => ollehar |
| 2021-03-03 16:00 | ollehar | Status | new => feedback |
| 2021-03-03 16:00 | ollehar | Note Added: 62683 | |
| 2021-03-03 18:31 | Mazi | Note Added: 62702 | |
| 2021-03-03 18:31 | Mazi | Status | feedback => assigned |
| 2021-03-04 16:36 | ollehar | Note Added: 62716 | |
| 2021-03-04 16:37 | ollehar | Note Added: 62717 | |
| 2021-03-04 16:37 | ollehar | Priority | none => normal |
| 2021-03-04 16:37 | ollehar | Description Updated | |
| 2021-03-04 16:37 | ollehar | Steps to Reproduce Updated | |
| 2021-03-04 16:41 | ollehar | Status | assigned => confirmed |
| 2021-03-04 16:41 | ollehar | Severity | block => partial_block |
| 2025-07-21 09:25 | algarvio | Bug heat | 6 => 12 |
| 2026-10-14 20:29 | c_schmitz | Changeset attached | => LimeSurvey master 63fd53a8 |
| 2026-10-14 20:29 | c_schmitz | Note Added: 86466 | |
| 2026-10-14 20:29 | c_schmitz | Assigned To | ollehar => c_schmitz |
| 2026-10-14 20:29 | c_schmitz | Status | confirmed => resolved |
| 2026-10-14 20:29 | c_schmitz | Resolution | open => fixed |
| 2026-10-14 20:29 | c_schmitz | Bug heat | 12 => 14 |