RobinHerbots / Inputmask

Input Mask plugin
https://robinherbots.github.io/Inputmask/
MIT License
6.39k stars 2.17k forks source link

Crash on large string [4.0.0] #1963

Open DiscoDancer opened 6 years ago

DiscoDancer commented 6 years ago

Hi.

I use version: 4.0.0

Steps to reproduce:

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);
RobinHerbots commented 6 years ago

@DiscoDancer ,

Can you provide an example of the data or a codepen with the mask and the value crashing the mask.

DiscoDancer commented 6 years ago

@RobinHerbots Hi, sorry for delay, I will provide it today or tomorrow.

DiscoDancer commented 6 years ago

https://codepen.io/anon/pen/LBarwr

Copy all text from this article and paste into input. It will have call stackoverflow and weird content

RobinHerbots commented 6 years ago

Thx, I will have a look around the codepen after my holidays

Op ma 13 aug. 2018 15:01 schreef Disco Dancer notifications@github.com:

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 .

mpryvkin commented 6 months ago

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.