Crash on large string [4.0.0]
Hi.
I use version: 4.0.0
Steps to reproduce:
- Apply input mask to input
- do copy and paste large text file (for example 200 lines HTML)
Error stack trace:
jquery.inputmask.bundle.min.js:9 Uncaught RangeError: Maximum call stack size exceeded
at Array.join (/native)
at O (jquery.inputmask.bundle.min.js:9)
at _ (jquery.inputmask.bundle.min.js:9)
at R (jquery.inputmask.bundle.min.js:9)
at F (jquery.inputmask.bundle.min.js:9)
at _ (jquery.inputmask.bundle.min.js:9)
at R (jquery.inputmask.bundle.min.js:9)
at F (jquery.inputmask.bundle.min.js:9)
at _ (jquery.inputmask.bundle.min.js:9)
at R (jquery.inputmask.bundle.min.js:9)
Configuration:
const companyCode = document.getElementById("companyCode") as HTMLInputElement;
const im = Inputmask("9999999-9", {
oncomplete: () => onMaskComplete(),
onincomplete: () => onMaskIncomplete(),
});
im.mask(companyCode);
@DiscoDancer ,
Can you provide an example of the data or a codepen with the mask and the value crashing the mask.
@RobinHerbots Hi, sorry for delay, I will provide it today or tomorrow.
https://codepen.io/anon/pen/LBarwr
Copy all text from this article and paste into input. It will have call stackoverflow and weird content
Thx, I will have a look around the codepen after my holidays
Op ma 13 aug. 2018 15:01 schreef Disco Dancer [email protected]:
https://codepen.io/anon/pen/LBarwr
Copy all text from this article https://en.wikipedia.org/wiki/Wolfgang_Amadeus_Mozart and paste into input. It will have call stackoverflow and weird content
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/RobinHerbots/Inputmask/issues/1963#issuecomment-412509862, or mute the thread https://github.com/notifications/unsubscribe-auth/AATb7_boljYoD5NMmp4v0PokV5Fb8Z-bks5uQXi3gaJpZM4Vzh9R .
Issue is still present on 5.0.8/5.0.9 and causes Maximum call stack size exceeded error in Google Chrome or too much recursion in Mozilla Firefox.
Solved by adding onBeforePaste callback handler and limiting pasted value to length defined by maxlength attribute or some sane default length. In my tests limiting pasted value length to 255 characters doesn't cause the problem anymore.