RobinHerbots / Inputmask

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

InputMask Exception > Length 500 #2567

Open codinglifestyle opened 2 years ago

codinglifestyle commented 2 years ago

"jQuery(document).ready(function() { jQuery('#ctl00_ctl00_ctl00ContentMainContentMainContentMainControlFormGroupControlGroupInformationRowOrderNotes_FormField_TextBox').inputmask({ regex: '[^<|>]*' }); });"

And in the code I can see, only when it gets past length 500 when pasting lots of garbage to test I get exception.

Error: "Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. [^<|>]*"

Seems to be caused by this: if (d > e + u._maxTestPos) throw "Inputmask: There is probably an error in your mask definition or in the code. Create an issue on github with an example of the mask you are using. " + s.mask;

where _maxTestPos is 500 for some reason.

codinglifestyle commented 2 years ago

As it seemed the code was arbitrarily defaulting to a max of 500 I tried specifying the maxlength attribute, It seems to have worked and I'm no longer seeing the error. The performance of the regex at 1000 characters was pretty slow however.

RobinHerbots commented 2 years ago

@codinglifestyle ,

I am wondering wheter I should remove the support for the textarea. The revalidation makes the input slow. But using a mask on a textarea is more used as a filter for input instead of really masking data I assume. Or I remove the support or I restrict to just validating the input without revalidating the "whole".

What do you think?

sanyi9305 commented 2 years ago

Hi,

What is the status of this?

codinglifestyle commented 2 years ago

RobinHerbots @RobinHerbots .

I am wondering wheter I should remove the support for the textarea. The revalidation makes the input slow. But using a mask on a textarea is more used as a filter for input instead of really masking data I assume. Or I remove the support or I restrict to just validating the input without revalidating the "whole".

What do you think?

Yes, really it is just using regex to block illegal characters. As you point out, nobody would be using a mask for something that is hundreds of characters.

Here is a funny example which was down to the backend system wanting to protect against special characters.

^[0-9A-Za-z]{2}[0-9A-Za-z_-/'&*,. ]{0,8}$

A lot of times content might be copy/pasted into the system.

MattPurland commented 10 months ago

RobinHerbots @RobinHerbots .

I am wondering wheter I should remove the support for the textarea. The revalidation makes the input slow. But using a mask on a textarea is more used as a filter for input instead of really masking data I assume. Or I remove the support or I restrict to just validating the input without revalidating the "whole". What do you think?

Yes, really it is just using regex to block illegal characters. As you point out, nobody would be using a mask for something that is hundreds of characters.

Here is a funny example which was down to the backend system wanting to protect against special characters.

^[0-9A-Za-z]{2}[0-9A-Za-z_-/'&*,. ]{0,8}$

A lot of times content might be copy/pasted into the system.

+1

I have this exact same problem.