binaryen icon indicating copy to clipboard operation
binaryen copied to clipboard

StringLowering: Escape the JSON in the custom section

Open kripken opened this issue 2 years ago • 1 comments

Also add an end-to-end test using node to verify we can parse the escaped content properly using TextDecoder+JSON.parse.

kripken avatar Feb 15 '24 18:02 kripken

PR now contains code point logic from Emscripten, that is hopefully correct... on a large real-world testcase it seems to parse everything properly at least.

kripken avatar Feb 16 '24 03:02 kripken

I ported the warning from the JS code to be more defensive here, and I added more comments in general. Did you have anything else in mind for defense/readability?

I added test coverage for all escaped characters.

kripken avatar Feb 20 '24 17:02 kripken

Last commit adds a test for a weird utf8 char, and fixes our handling of the escape codes.

kripken avatar Feb 20 '24 18:02 kripken

I plan to try to rewrite this to be safer and easier to understand, so LGTM as-is for the short term.

tlively avatar Feb 20 '24 20:02 tlively