Inputmask icon indicating copy to clipboard operation
Inputmask copied to clipboard

Crash on large string [4.0.0]

Open DiscoDancer opened this issue 7 years ago • 5 comments

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 avatar Aug 08 '18 08:08 DiscoDancer

@DiscoDancer ,

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

RobinHerbots avatar Aug 09 '18 07:08 RobinHerbots

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

DiscoDancer avatar Aug 13 '18 06:08 DiscoDancer

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

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

DiscoDancer avatar Aug 13 '18 13:08 DiscoDancer

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 .

RobinHerbots avatar Aug 13 '18 13:08 RobinHerbots

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.

mpryvkin avatar Mar 16 '24 16:03 mpryvkin