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

Client side escaping bug prevents using any advanced commands with escaped JSON #92

Open
vorburger opened this issue Jul 1, 2018 · 3 comments

Comments

@vorburger
Copy link
Member

vorburger commented Jul 1, 2018

If one currently uses our / [command] block with anything non-trivial, e.g. like this (BTW note the use of a fixed user name instead of @p due to #91):

give michaelpapa7 written_book 1 0 {pages:["{\"text\":\"Hello\"}"],title:"First Quest",author:"https://www.learn.study",display:{Lore:["The first quest is your first test..."]}} 

this does not work. There is nothing on the server log, but the Browser's Console has this:

Uncaught SyntaxError: Invalid or unexpected token

so looks like we're screwing up / missing some escaping of the JSON-like Minecraft "data" String at some stage? We probably should be correctly escaping anything end-users put into the white spaces in Scratch blocks before we send the through Vert.x into our back-end.

@edewit FYI and perhaps this is something you would like to have a go at, some time.

@vorburger vorburger changed the title Client side escaping bug prevents using any interesting commands Client side escaping bug prevents using any advanced commands with escaped JSON Aug 20, 2018
@vorburger
Copy link
Member Author

Basic escaping actually works - the problem with the command above is that it contains JSON which itself contains embedded escaped JSON.. that's a bit particular, but Minecraft does this e.g. for the Books.

I've attempted to fix this in https://github.com/vorburger/minecraft-storeys-maker/compare/issue92_runCommand-encoding (where at least in the current version with the first commit the test does NOT actually pass), but can't for the life of me get the replace and RegExp in JS to work correctly... I'm not sure if Vert.x is doing some additional escaping, or if I'm just dumb.

@edewit if you can spot what I'm doing wrong, please shout / amend that branch. I've already tried '\\"" instead of '\"" - that doesn't help.

@vorburger vorburger removed the Blocker label Aug 20, 2018
@vorburger
Copy link
Member Author

BTW: That new test (above) does NOT even print Uncaught SyntaxError: Invalid or unexpected token, so perhaps there are several problems here? Like escaping issue from the block in Flash to a JS extension AND on our side? This may be easier in Scratch 3 than 2.

@vorburger
Copy link
Member Author

Yeah that (above) is the real problem here... this seems to be an escaping related bug in the Scratch (v2) Flash-to-JS bridge! It works and I can give myself fancy book if I put this into our '/' command block - note the double \\" here:

give michaelpapa7 written_book 1 0 {pages:["{\\"text\\":\\"Hello\\"}"],title:"First Quest",author:"https://www.learn.study",display:{Lore:["The first quest is your first test..."]}} 

That's a good-enough workaround. I'll mark this issue as a Low and post-Scratch3 problem...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

1 participant