1

Javascriptlet evaluates backslash escape codes in variables

The Javascriptlet action changes the values of variables that contain backslash escape codes by evaluating them, even if the JavaScript code doesn't touch that variable.

This task demonstrates the problem:

Bug in Javascriptlet (127)
<Other backslash codes also break>
A1: Variable Set [ Name:%data To:\\ Recurse Variables:Off Do Maths:Off Append:Off Max Rounding Digits:3 ]
<Stores 2>
A2: Test Variable [ Type:Length Data:%data Store Result In:%data_length ]
<Code must contain an identifier, even if it is commented out.>
A3: JavaScriptlet [ Code:// something Libraries: Auto Exit:On Timeout (Seconds):45 ]
<Stores 1>
A4: Test Variable [ Type:Length Data:%data Store Result In:%data_length_after ]
A5: Flash [ Text:Not good!
%data_length vs %data_length_after Long:Off ] If [ %data_length != %data_length_after ]

Link to import that task

I originally ran into this while trying to parse some JSON retrieved via HTTP Request. Sometimes it worked and sometimes it didn't, and the times it didn't were when one of the fields in the JSON data contained a "\\". That seems to indicate this happens before the code actually runs (probably while "importing" local variables to the JS), thereby invalidating the JSON (since the character behind the resulting single "\" wasn't valid in JSON).

I'm using 59.3.beta.2, but I didn't go back to the non-beta version to check if it used to work before. I also didn't check whether the Javascript action has the same bug.

3 replies

Hhmm, I'm getting length 2 for both. Can you please try this version? https://drive.google.com/file/d/1UfMEt1H6wjlMDdsqByn-flCRqE45PdJ1/view?usp=sharing

With that version the original task doesn't reproduce it anymore for me either, but a slightly altered version (changing the javascript to include the variable name) still does.

Ok, I may have fixed that too. :) Can you please try this version? https://drive.google.com/file/d/1UfMEt1H6wjlMDdsqByn-flCRqE45PdJ1/view?usp=sharing

Still not quite right unfortunately, see this version.

The variables now appear unaltered after Javascript execution, but during execution they still seem to have the wrong value... 😕 

Thanks, I need to figure out another way entirely. Seems like the last change broke some other situations too...