Inputmask icon indicating copy to clipboard operation
Inputmask copied to clipboard

InputMask Exception > Length 500

Open codinglifestyle opened this issue 3 years ago • 5 comments

  • I was testing a feature on a textarea but encountered this unexpected bug. Here is the auto-generated code which kicks off inputmask:

"jQuery(document).ready(function() { jQuery('#ctl00_ctl00_ctl00__ContentMain__ContentMain__ContentMain__ControlFormGroup__ControlGroupInformation__RowOrderNotes_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.

  • Add a link to a codepen, jsfiddle or other example page which shows the problem
  • OS: Win10
  • Browser: IE, Chrome
  • Inputmask 5.0.6

codinglifestyle avatar Nov 17 '21 17:11 codinglifestyle

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.

codinglifestyle avatar Nov 19 '21 13:11 codinglifestyle

@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?

RobinHerbots avatar Dec 17 '21 13:12 RobinHerbots

Hi,

What is the status of this?

sanyi9305 avatar Feb 28 '22 11:02 sanyi9305

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.

codinglifestyle avatar Mar 07 '22 15:03 codinglifestyle

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.

MattPurland avatar Oct 11 '23 06:10 MattPurland