JScrewIt icon indicating copy to clipboard operation
JScrewIt copied to clipboard

'\xxx' not recognized

Open 837951602 opened this issue 8 years ago • 3 comments

'\040' 28903 bytes as Function("return '\040'")() instead of directly describe char32(space)?

837951602 avatar Feb 08 '17 10:02 837951602

Thanks for reporting this. The reason why JScrewIt does not parse octal escape sequences is that they are illegal in strict mode. For example, ES6 modules are always strict mode code. A script containing the literal '\040' must produce a syntax error when it is loaded as a module, but this would not happen if the escape sequence were resolved by the parser and encoded like an unescaped character.

I think a good solution is adding a feature to explicitly enable octal escape sequences and legacy octal numbers. In the UI, this would be enabled in all compatibility modes except maximum compatibility and custom compatibility when the option "Generate strict mode code" is checked.

fasttime avatar Feb 08 '17 15:02 fasttime

A feature "NON_STRICT" containing "INCR_CHAR" and "LEGAL_OCT" and etc?

837951602 avatar Mar 14 '17 14:03 837951602

There should be a feature "LEGACY_OCT". A combined feature "NON_STRICT" wouldn't be particularly useful because both "INCR_CHAR" and "LEGACY_OCT" would be already available in all engines.

The point is that some strict mode restrictions are not properly enforced everywhere: Node.js <= 4 forbids legacy octals in strict mode but allows increments on chars; IE 9 in strict mode allows both.

Anyway there is already a strict mode environment, it's called "forced-strict-mode". This is now used to remove "INCR_CHAR" in strict mode from some engines but not from others (precisely from engines with the attribute "char-increment-restriction"). The same method should be used for legacy octals when the new feature is introduced.

fasttime avatar Mar 14 '17 22:03 fasttime