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

Restrict allowed variable symbols & reserved words #20

Open
12 tasks
justsml opened this issue May 20, 2022 · 0 comments
Open
12 tasks

Restrict allowed variable symbols & reserved words #20

justsml opened this issue May 20, 2022 · 0 comments

Comments

@justsml
Copy link
Contributor

justsml commented May 20, 2022

For all variable/token names:

  • Prevent any special symbols or operators in names.
    • Opt 1: Filtering ~``!@#$%^&*()-_=+{}|[]\;:'<>?,./ - exclusionary approach can allow strange edge cases and must account for the endless strangeness of Unicode special symbols.
    • Opt 2: Must match ^[a-zA-Z0-9\.\-_]+$ - restricted can limit use cases, but much safer.
  • Exclude all builtin JS functions & internal operation names.
    • parseInt, parseFloat, (there's an NPM package with arrays of this...)
    • Get a dynamic list of prefixOps and infixOps. (need to export from the expression-language/index.)
  • No lone or dotted numbers (avoids some array/index collisions & weirdness.)
    • 42 = 'Antwerd'
    • 42.24 = 'Antwerd'
    • words[42] = 'Antwerd'
  • Throw error on dangerous Object.prototype.... methods.
    • valueOf, toString, toJSON, etc.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant