View Issue Details

IDProjectCategoryView StatusLast Update
15598Bug reportsExpression Managerpublic2020-01-28 17:39
ReporterDenisChenu Assigned ToDenisChenu  
PrioritynoneSeverityminor 
Status closedResolutionfixed 
Product Version3.20.x 
Target Version4.0.x 
Summary15598: intval : broken interpretation of string start by integer in JS
DescriptionIn js intval('150.03_page-section') return an empty string and 150 iun PHP

Steps To ReproduceImport included survey : test
Additional Informationhttps://locutus.io/php/var/intval/index.html

and in php intval("aa") return 0 … not an empty string
TagsNo tags attached.
Complete LimeSurvey version number (& build)3.20.2
I will donate to the project if issue is resolvedNo
Browserff
Database & DB-Versionmariadb
Server OS (if known)not relevant ?
Webserver software & version (if known)not relevant ?
PHP Versionphp7.2

Relationships

related to 15513 closedDenisChenu Feature requests Missing function floatval() in EM 

Activities

DenisChenu

DenisChenu

2019-11-20 12:26

developer  

ollehar

ollehar

2019-11-20 14:59

administrator   ~54710

Shit.
ollehar

ollehar

2019-11-20 15:00

administrator   ~54711

Even with this? https://www.w3resource.com/phpjs/variable/intval.php
DenisChenu

DenisChenu

2019-11-20 15:10

developer   ~54712

phpjs is dead and replaced by locutus :)

Current
https://github.com/LimeSurvey/LimeSurvey/blob/0abf282a540c71c8a6c1c6ebd68616f678ed9cee/assets/scripts/expressions/em_javascript.js#L205-L211
````
    if (isNaN(a)) {
        return NaN;
    }
    return Math.floor(+a);
````
DenisChenu

DenisChenu

2019-11-20 15:11

developer   ~54713

https://locutus.io/2016/05/announcing-locutus/
DenisChenu

DenisChenu

2019-11-20 15:12

developer   ~54714

Last edited: 2019-11-20 15:13

View 2 revisions

And please : if possible less tracker in links ;)

w3resource have (at minima) 14 trackers

DenisChenu

DenisChenu

2019-11-20 15:16

developer   ~54715

Another issue `-3.1` return -4 in js … (-3 in php)

`return mixedVar < 0 ? Math.ceil(mixedVar) : Math.floor(mixedVar)`
ollehar

ollehar

2019-11-20 15:31

administrator   ~54716

> And please : if possible less tracker in links ;)

I always use NoScript.
DenisChenu

DenisChenu

2019-11-20 15:35

developer   ~54717

NoScript and LimeSurvey admin \o/

PS : NoScript is not a no tracker warranty
ollehar

ollehar

2019-11-20 15:54

administrator   ~54718

> Another issue -3.1 return -4 in js … (-3 in php)

Nightmare...
ollehar

ollehar

2019-11-20 15:55

administrator   ~54719

No:

> parseInt("-3.1") --> -3
DenisChenu

DenisChenu

2019-11-20 15:56

developer   ~54720

I mean LEMintval(-3.1) == 4

Check with included survey
ollehar

ollehar

2019-11-20 16:06

administrator   ~54721

> I mean LEMintval(-3.1) == 4

#$*%&^(#*$&%^
DenisChenu

DenisChenu

2019-11-20 16:16

developer   ~54722

:mdr: :ptdr: (you can't understand , it's i really have a big laugh in french pre 2000 forum)
DenisChenu

DenisChenu

2020-01-21 07:43

developer   ~55394

https://github.com/LimeSurvey/LimeSurvey/pull/1367

I don't know if i assign it to you or @ollehar when it's on testing
ollehar

ollehar

2020-01-21 15:32

administrator   ~55410

> Import included survey : test

Can you elaborate on this? How to reproduce.

1. Import survey
2. Preview survey
3. See bla bla bla? Should see bla bla bla?
DenisChenu

DenisChenu

2020-01-21 15:42

developer   ~55411

1. Import survey
2. Click on Preview survey
3. Click on Next
4. Look at result of intval
5. Next
6. Look at result of intval
DenisChenu

DenisChenu

2020-01-21 15:57

developer   ~55412

Alternative
Import limesurvey_survey_15598_intval_floatval_jsphp_compare.lss
or attached lss in 3.X (4.X export are not 3.X compatible …)

Test survey with only move next … : see screencast
Peek 21-01-2020 15-55.gif (1,179,928 bytes)
ollehar

ollehar

2020-01-21 16:33

administrator   ~55413

Good shit, Denis, thank you.
ollehar

ollehar

2020-01-21 17:18

administrator   ~55414

Test failed? I see the exact same end page in your branch as in master branch.
Selection_983.png (42,667 bytes)   
Selection_983.png (42,667 bytes)   
DenisChenu

DenisChenu

2020-01-21 17:33

developer   ~55415

> Test failed? I see the exact same end page in your branch as in master branch.

Yes : the PHP are not updated. There are difference between variables in same page and variable in different page ( JS vs PH°.
To check : after see the end page , move previous and check …
DenisChenu

DenisChenu

2020-01-21 17:35

developer   ~55416

Last edited: 2020-01-21 17:35

View 2 revisions

Mayeb must be

4. Look at result of intval : check it `''`
5. Next
6. Look at result of intval : check it `150`

DenisChenu

DenisChenu

2020-01-22 13:47

developer   ~55431

Fix committed to master branch: http://bugs.limesurvey.org/plugin.php?page=Source/view&id=29430
lime_release_bot

lime_release_bot

2020-01-28 17:39

administrator   ~55537

Fixed in Release 4.1.0+200128

Related Changesets

LimeSurvey: master e865cdee

2020-01-22 13:47:45

DenisChenu


Committer: ollehar Details Diff
Fixed issue 15598: intval : broken interpretation of string start by integer in JS (#1367)

Dev: updated expression JS function, inspired by locutus
Dev: add Test function compating JS and PHP with different combination
Affected Issues
15598
mod - assets/packages/expressions/em_javascript.js Diff File
add - tests/data/surveys/limesurvey_survey_15598_intval_floatval_jsphp_compare.lss Diff File
add - tests/functional/frontend/IntvalFloatvalTest.php Diff File

Issue History

Date Modified Username Field Change
2019-11-20 12:26 DenisChenu New Issue
2019-11-20 12:26 DenisChenu File Added: limesurvey_survey_brokenIntVal.lss
2019-11-20 12:36 DenisChenu Relationship added related to 15513
2019-11-20 14:59 ollehar Note Added: 54710
2019-11-20 15:00 ollehar Note Added: 54711
2019-11-20 15:10 DenisChenu Note Added: 54712
2019-11-20 15:11 DenisChenu Note Added: 54713
2019-11-20 15:12 DenisChenu File Added: Capture d’écran du 2019-11-20 15-12-06.png
2019-11-20 15:12 DenisChenu Note Added: 54714
2019-11-20 15:13 DenisChenu Note Edited: 54714 View Revisions
2019-11-20 15:16 DenisChenu Note Added: 54715
2019-11-20 15:31 ollehar Note Added: 54716
2019-11-20 15:35 DenisChenu Note Added: 54717
2019-11-20 15:54 ollehar Note Added: 54718
2019-11-20 15:55 ollehar Note Added: 54719
2019-11-20 15:56 DenisChenu File Added: Capture d’écran du 2019-11-20 15-56-20.png
2019-11-20 15:56 DenisChenu Note Added: 54720
2019-11-20 16:06 ollehar Note Added: 54721
2019-11-20 16:16 DenisChenu Note Added: 54722
2020-01-13 14:36 DenisChenu Assigned To => DenisChenu
2020-01-13 14:36 DenisChenu Status new => assigned
2020-01-13 14:37 DenisChenu Target Version => 4.0.x
2020-01-21 07:43 DenisChenu Assigned To DenisChenu => cdorin
2020-01-21 07:43 DenisChenu Status assigned => testing
2020-01-21 07:43 DenisChenu Note Added: 55394
2020-01-21 15:32 ollehar Note Added: 55410
2020-01-21 15:42 DenisChenu File Added: limesurvey_survey_15598_intval_floatval_jsphp_compare.lss
2020-01-21 15:42 DenisChenu File Added: Capture d’écran du 2020-01-21 15-41-10.png
2020-01-21 15:42 DenisChenu File Added: Capture d’écran du 2020-01-21 15-41-19.png
2020-01-21 15:42 DenisChenu Note Added: 55411
2020-01-21 15:57 DenisChenu File Added: limesurvey_survey_redoFloatIntTest.lss
2020-01-21 15:57 DenisChenu File Added: Peek 21-01-2020 15-55.gif
2020-01-21 15:57 DenisChenu Note Added: 55412
2020-01-21 16:33 ollehar Note Added: 55413
2020-01-21 17:18 ollehar File Added: Selection_983.png
2020-01-21 17:18 ollehar Note Added: 55414
2020-01-21 17:33 DenisChenu Note Added: 55415
2020-01-21 17:35 DenisChenu Note Added: 55416
2020-01-21 17:35 DenisChenu Note Edited: 55416 View Revisions
2020-01-22 13:47 ollehar Changeset attached => LimeSurvey master e865cdee
2020-01-22 13:47 DenisChenu Note Added: 55431
2020-01-22 13:47 DenisChenu Assigned To cdorin => DenisChenu
2020-01-22 13:47 DenisChenu Resolution open => fixed
2020-01-22 14:53 ollehar Status testing => resolved
2020-01-28 17:39 lime_release_bot Note Added: 55537
2020-01-28 17:39 lime_release_bot Status resolved => closed