uNmAnNeR / imaskjs

vanilla javascript input mask
https://imask.js.org
MIT License
4.91k stars 256 forks source link

Infinite recursion while processing year with `autofix: "pad"` #1054

Open BadCoder1337 opened 2 months ago

BadCoder1337 commented 2 months ago

Describe the bug Date mask throws an error when user tries to enter a 2-digit year into a 4-digit block.

Uncaught RangeError: Maximum call stack size exceeded
    at get displayValue (/node_modules/imask/dist/imask.js:2202:21)
    at MaskedRange._appendCharRaw (/node_modules/imask/dist/imask.js:2227:50)
    at MaskedRange._appendCharRaw (/node_modules/imask/dist/imask.js:2535:24)
    at MaskedRange._appendCharRaw (/node_modules/imask/dist/imask.js:2535:89)
    at MaskedRange._appendCharRaw (/node_modules/imask/dist/imask.js:2535:89)
    ......

To Reproduce CodeSandbox Type 1.1.21 to the field.

Expected behavior Input field shoud reject user input or pad with apropriate digit like 1111 -> 1951

Environment:

Additional context I want to additionally support 2-digit year in the date field. E.g. upon Enter check accepted value. If it's a 2-digit year convert it to a full year.

brunobely commented 1 month ago

Not sure if related but getting the same error when entering a completely off value via autocomplete, like 12/3123211231_/yyyy on a Date mask (which I guess shouldn't even be allowed in the first place).