rules-machine
rules-machine copied to clipboard
Restrict allowed variable symbols & reserved words
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.
- [ ] Opt 1: Filtering
- [ ] 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
andinfixOps
. (need to export from theexpression-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.
- [ ]