keyman icon indicating copy to clipboard operation
keyman copied to clipboard

bug(developer): compiler generates invalid javascript for unquoted numbers in `if()` statements

Open mcdurdin opened this issue 2 years ago • 0 comments

Describe the bug

if(option_key_t_is_tyun = 1) U+221A + [NCAPS K_T] > set(option_key_t_is_tyun = '0') save(option_key_t_is_tyun)

This generates invalid javascript: it generates a store with a value of "\x1", which must be "\x01" to work.

The source keyboard: armenian_mnemonic from https://community.software.sil.org/t/text-suggestion-not-working-in-some-cases/6490/4 (armenian_mnemonic.zip)

Proposed mitigations:

  1. always generate minimum 2 char hexadecimal sequences.
  2. possibly, hint that an unquoted number might not be expected?
  3. not really related, but compress the list of compared store values so we don't end up with hundreds of them in the compiled keyboard.

Keyman Developer:

  • OS: any
  • Keyman Developer version: 15.0.267

mcdurdin avatar Jul 28 '22 01:07 mcdurdin