Bug - Fixed Don't escape HTML entities when executing "js" command

philmasterplus

Active member
When JavaScript code is executed with the gCLI js command, the entire string is processed with CharacterEntities.unescape() before being passed to the JavaScript interpreter. While this behavior is standard for most gCLI commands, it makes debugging JS one-liners difficult.

In contrast, the ash command is special-cased to receive HTML entities as is. It would be nice to give the js command the same treatment.

Example in the gCLI:
Code:
> ash "&".length()
Returned: 5

> js "&".length
Returned: 1

The special-casing code is at line 336 of KoLmafiaCLI.java:
Java:
        // Pass through escaped character entities to ASH
        if ( !line.startsWith( "ash" ) )
        {
            line = CharacterEntities.unescape( line );
        }

This can be easily fixed by special-casing the js command, too:
Java:
        // Pass through escaped character entities to ASH and JS
        if ( !(line.startsWith( "ash" ) || line.startsWith( "js" )) )
        {
            line = CharacterEntities.unescape( line );
        }

Attached is a patch file containing the fix.
 

Attachments

  • philmasterplus-js-command-no-entity-escape.patch
    778 bytes · Views: 2

gausie

D̰͕̝͚̤̥̙̐̇̑͗̒e͍͔͎͈͔ͥ̉̔̅́̈l̠̪̜͓̲ͧ̍̈́͛v̻̾ͤe͗̃ͥ̐̊ͬp̔͒ͪ
Staff member
r20661, thank you
 
Top