[E][P] Escape Characters in Expressions Not Working

Post about any bugs or other issues that you find on AAO.

Moderator: EN - Forum Moderators

Post Reply
User avatar
TimeAxis
Posts: 389
Joined: Fri Jan 01, 2021 8:27 pm
Spoken languages: English
Contact:

[E][P] Escape Characters in Expressions Not Working

Post by TimeAxis »

User Agent String: Tested on both Firefox and Chrome:
Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:106.0) Gecko/20100101 Firefox/106.0
Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
Link: https://aaonline.fr/player.php?trial_id=143966&debug

What happened?:
When defining a variable's value to a string that includes an escape character ( \ ) for the purpose of adding a single or double quote to the string, (for example, the string 'this won\'t work'), the value is not written at all, and returns an "Uncaught TypeError: read-only" error.

What did you expect to happen?:
Based on the fact that inputting a string with quotes into a field, and then hitting the "Advanced mode" and "Load from runtime expression" checkboxes causes escape characters to be filled out automatically, and the fact that expression_engine.js seems to have code devoted to detecting escape characters, I would expect them to cause quotes to be considered part of the string. Worst case, I would expect the expression to return as red in the editor. It does not.

Can you reproduce the problem?:
Yes, it happens every time in the example trial linked above. The firefox debugger may not return the error unless you have the Variables panel open in the player.

What did you do before the problem showed up?:
Defined any variable to a string with an escape character in it.

Error returned on Firefox:

Code: Select all

Uncaught TypeError: 8 is read-only
    decompose https://aaonline.fr/Javascript/expression_engine.js?v=1646564063:93
    parse https://aaonline.fr/Javascript/expression_engine.js?v=1646564063:363
    eval https://aaonline.fr/Javascript/expression_engine.js?v=1646564063:530
    evaluate_expression https://aaonline.fr/Javascript/expression_engine.js?v=1646564063:542
    loadParameterScalar https://aaonline.fr/Javascript/actions_parameters.js?v=1646564063:82
    computeParameters https://aaonline.fr/Javascript/actions_parameters.js?v=1646564063:100
    recursiveHandle https://aaonline.fr/Javascript/actions_parameters.js?v=1646564063:30
    recursiveHandle https://aaonline.fr/Javascript/actions_parameters.js?v=1646564063:41
    recursiveHandle https://aaonline.fr/Javascript/actions_parameters.js?v=1646564063:41
    recursiveHandle https://aaonline.fr/Javascript/actions_parameters.js?v=1646564063:41
    recursiveHandle https://aaonline.fr/Javascript/actions_parameters.js?v=1646564063:41
    handleScalarValuesRecursively https://aaonline.fr/Javascript/actions_parameters.js?v=1646564063:52
    computeParameters https://aaonline.fr/Javascript/actions_parameters.js?v=1646564063:98
    readFrame https://aaonline.fr/Javascript/player.js?v=1646564063:269
    player_init https://aaonline.fr/Javascript/player.js?v=1646564063:180
    registerEventHandler https://aaonline.fr/Javascript/events.js?v=1646564063:38
    player_init https://aaonline.fr/Javascript/player.js?v=1646564063:171
    init https://aaonline.fr/Javascript/player.js?v=1646564063:21
    requestFiles https://aaonline.fr/Javascript/language.js?v=1646564063:77
    complete https://aaonline.fr/Javascript/language.js?v=1646564063:57
    onreadystatechange https://aaonline.fr/Javascript/language.js?v=1646564063:106
    includeLanguage https://aaonline.fr/Javascript/language.js?v=1646564063:93
    request https://aaonline.fr/Javascript/language.js?v=1646564063:44
    requestFiles https://aaonline.fr/Javascript/language.js?v=1646564063:68
    init https://aaonline.fr/Javascript/player.js?v=1646564063:19
    complete https://aaonline.fr/player.php?trial_id=143966&debug:195
    wake_up_depending_on https://aaonline.fr/player.php?trial_id=143966&debug:254
    complete https://aaonline.fr/player.php?trial_id=143966&debug:209
    <anonymous> https://aaonline.fr/Javascript/actions_parameters.js?v=1646564063:162
Error Returned on Chrome:

Code: Select all

Uncaught TypeError: Cannot assign to read only property '8' of string 'this won\'
    at ExpressionEngine.decompose (expression_engine.js?v=1646564063:93:32)
    at ExpressionEngine.parse (expression_engine.js?v=1646564063:363:16)
    at ExpressionEngine.eval (expression_engine.js?v=1646564063:530:29)
    at evaluate_expression (expression_engine.js?v=1646564063:542:13)
    at loadParameterScalar (actions_parameters.js?v=1646564063:82:11)
    at actions_parameters.js?v=1646564063:100:15
    at recursiveHandle (actions_parameters.js?v=1646564063:30:7)
    at recursiveHandle (actions_parameters.js?v=1646564063:41:8)
    at recursiveHandle (actions_parameters.js?v=1646564063:41:8)
    at recursiveHandle (actions_parameters.js?v=1646564063:41:8)
ExpressionEngine.decompose @ expression_engine.js?v=1646564063:93
ExpressionEngine.parse @ expression_engine.js?v=1646564063:363
ExpressionEngine.eval @ expression_engine.js?v=1646564063:530
evaluate_expression @ expression_engine.js?v=1646564063:542
loadParameterScalar @ actions_parameters.js?v=1646564063:82
(anonymous) @ actions_parameters.js?v=1646564063:100
recursiveHandle @ actions_parameters.js?v=1646564063:30
recursiveHandle @ actions_parameters.js?v=1646564063:41
recursiveHandle @ actions_parameters.js?v=1646564063:41
recursiveHandle @ actions_parameters.js?v=1646564063:41
recursiveHandle @ actions_parameters.js?v=1646564063:41
handleScalarValuesRecursively @ actions_parameters.js?v=1646564063:52
computeParameters @ actions_parameters.js?v=1646564063:98
readFrame @ player.js?v=1646564063:269
(anonymous) @ player.js?v=1646564063:180
Possible Fix:
Removing a couple of seemingly unnecessary lines in expression_engine.js appears to fix the issue.
See pull request here: https://bitbucket.org/AceAttorneyOnline ... working-in

Workaround:
For those who might be looking for a workaround in case this doesn't get fixed, you can do the following:
Define a variable as just the character ' or " (do not use advanced mode to do this), then you can concatenate that variable to the string you want to have ' or " in it. For example:

Code: Select all

chr_sqt = ' (Not defined in advanced mode)
newString = 'this won' . chr_sqt . 't fail to work'
Image
Question Arcs (Threads Coming Eventually)
ImageImageImageImage
Gaiden Episodes
Champion of Turnabouts ★
HALLOWEEN HERO
Other
Phoenix Wright: Ace Attornauts
The Curious Case of the Phantom Limousine (Coming Eventually)
The Imposter's Turnabout (Coming Maybe)
Post Reply