samualtnorman / hackmud-script-manager

Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.
https://www.npmjs.com/package/hackmud-script-manager
MIT License
11 stars 5 forks source link

not using quine cheated version in weird case #158

Open samualtnorman opened 7 months ago

samualtnorman commented 7 months ago
export default args => args.foo(`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`)

quine cheats to 98 chars

function(a){return a.foo("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")}

but

export default args => args.foo(`aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`)

quine cheats to 77 chars

function(o){
//  ["foo","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]   
let[$,n]=JSON.parse(#fs.scripts.quine().split`  `[1])
return o[$](n)}

despite the source being longer

Kyromyr commented 7 months ago

This happens because the quined/non-quined selection comes before postprocessing. At this point the scripts are

function _0a3zb0ymxzr_SCRIPT_(a){return a.foo("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa")}

and

function _0m9hbj02g1l_SCRIPT_($){
//  ["foo","aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"]   
let[l,t]=JSON.parse($0m9hbj02g1l$SUBSCRIPT$scripts$quine$().split`  `[1])
return $[l](t)}
samualtnorman commented 7 months ago

ah, you're right. thank you for spotting this