Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Golfing incorrectly escapes (s and )s #178

Open
Argonius-Angelus opened this issue May 4, 2024 · 5 comments
Open

Golfing incorrectly escapes (s and )s #178

Argonius-Angelus opened this issue May 4, 2024 · 5 comments
Labels
affects-usability Might turn off new users from using this tool bug Something isn't working question Further information is requested

Comments

@Argonius-Angelus
Copy link

Argonius-Angelus commented May 4, 2024

I'm dealing with a big lack of sleep here while writing this, but much like #172 there's some seriously odd behavior that can emerge when golfing a script that contains scripts.quine in some form, as well as strings like "e)(ecutioner". This breaks the JSON parser for some reason.

Basically, if (s or )s exist inside the cheated strings, don't escape them, as for some reason that makes them transcend the string itself and murders the parser. As soon as I removed the \s escaping the (s and )s within those strings, it stopped erroring.

@Argonius-Angelus
Copy link
Author

Argonius-Angelus commented May 4, 2024

If you want to recreate this, you can attempt to use hsm golf on vecna.eye in game, as passing empty params to it has it dump the source code for you to copy and play around with.

@samualtnorman
Copy link
Owner

please can you give a minimal reproduction? thanks

@samualtnorman samualtnorman added the question Further information is requested label May 4, 2024
@Argonius-Angelus
Copy link
Author

function(context,args){
    args = args || {}
	if (args.name == "testing"){
        return #fs.scripts.quine()
    }
}

when hsm golf is run on it spits out

function(t,$){
//	["name","testing","function(context,args){\n    args = args || {}\n\tif (args.name == \"testing\"){\n        return #fs.scripts.quine\()\n    }\n}"]	
let[e,s,i]=JSON.parse(#fs.scripts.quine().split`	`[1])
if(($=$||{})[e]==s)return i}

This, when run regardless of params, should cause the following error to appear :::TRUST COMMUNICATION::: SyntaxError: Unexpected token ( in JSON at position 134
This is because the ( in #fs.scripts.quine() is being escaped.

@samualtnorman
Copy link
Owner

ah, good catch

@samualtnorman
Copy link
Owner

I've added a fix.

You can install the @dev version of the package to test if the fix works:

  • If you have HSM installed globally, update it with npm install -g hackmud-script-manager@dev
  • Or if you're using Hackmud Scripting Environment, run this in the folder pnpm add hackmud-script-manager@dev

If you then afterwards want to return to the latest proper release, run the same command again but replace @dev with @latest.

@samualtnorman samualtnorman added bug Something isn't working affects-usability Might turn off new users from using this tool labels May 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
affects-usability Might turn off new users from using this tool bug Something isn't working question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants