Opened 4 years ago

Closed 3 years ago

#18841 closed defect (wontfix)

Long repeated regex in ValidationTextBox causes UI to hang

Reported by: dmgdpnk Owned by: bill
Priority: undecided Milestone: 1.11.3
Component: Dijit - Form Version: 1.6.3
Keywords: Cc:
Blocked By: Blocking:

Description

I have a long repeated regex as input validation for a ValidationTextBox? but the repeat operator (* or +) is causing the page to hang. Please see the jsfiddle link below: http://jsfiddle.net/ce2xb0rn/

Removing the repeat operator stops the hang but it is required for my comma separated pattern validation.

Attachments (2)

longRegex.html (1.2 KB) - added by bill 3 years ago.
stand alone test case
long-regex-with-workaround.html (1.3 KB) - added by bill 3 years ago.
working version of code, using workaround

Download all attachments as: .zip

Change History (6)

comment:1 Changed 4 years ago by bill

I don't know what's causing it, but my guess is that it's related to the "partial regex" code from ValidationTextBox#_computeRegexp?(), which converts the original regex into one that also matches text could become valid by typing more characters. For example, since "90210" is a valid US zipcode, the partial regex will match "902" but not "90a" or "902109". If you are trying to find a workaround, I'd search there.

comment:2 Changed 3 years ago by dylan

Milestone: tbd1.11.3

comment:3 Changed 3 years ago by bill

As predicted by the ticket, the jsfiddle hangs, but the essence of the test case is:

<input dojoType="dijit.form.ValidationTextBox" name="ewr" required="true"
regexp='((^|,[ ]?)(permit|PERMIT|deny|DENY):(ip|IP|tcp|TCP|udp|UDP)(:(((([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5]))((\/([1-9]|[1-2][0-9]|3[0-2]))?)|any|ANY):([0-9]|[0-9]{2}|[0-9]{3}|[0-9]{4}|[0-5][0-9]{4}|6[0-4][0-9]{3}|65[0-4][0-9]{2}|655[0-2][0-9]|6553[0-5]|any|ANY|bgp|BGP|bootpc|BOOTPC|bootps|BOOTPS|domain|DOMAIN|echo|ECHO|ftp|FTP|ftp-data|FTP-DATA|isakmp|ISAKMP|msrpc|MSRPC|nameserver|NAMESERVER|non500-isakmp|NON500-ISAKMP|ntp|NTP|pop3|POP3|smtp|SMTP|snmp|SNMP|snmptrap|SNMPTRAP|sunrpc|SUNRPC|syslog|SYSLOG|tacacs|TACACS|telnet|TELNET|tftp|TFTP|www|WWW)){2})*'
promptmessage="Enter a string. " onChange="validateTemplateValidateText()" isglobalvariable="false" type="text"/>

Changed 3 years ago by bill

Attachment: longRegex.html added

stand alone test case

comment:4 Changed 3 years ago by bill

Resolution: wontfix
Status: newclosed

OK, I debugged your example, and ValidationTextBox#_computeRegexp() returns this:

((^|(?:,|$)(?:[ ]|$)?|$)((?:p|$)(?:e|$)(?:r|$)(?:m|$)(?:i|$)(?:t|$)|(?:P|$)(?:E|$)(?:R|$)(?:M|$)(?:I|$)(?:T|$)|(?:d|$)(?:e|$)(?:n|$)(?:y|$)|(?:D|$)(?:E|$)(?:N|$)(?:Y|$)|$)(?::|$)((?:i|$)(?:p|$)|(?:I|$)(?:P|$)|(?:t|$)(?:c|$)(?:p|$)|(?:T|$)(?:C|$)(?:P|$)|(?:u|$)(?:d|$)(?:p|$)|(?:U|$)(?:D|$)(?:P|$)|$)((?::|$)(((((?:[0-9]|$)|(?:[1-9]|$)(?:[0-9]|$)|(?:1|$)(?:[0-9]|$){2}|(?:2|$)(?:[0-4]|$)(?:[0-9]|$)|(?:2|$)(?:5|$)(?:[0-5]|$)|$)(?:\.|$)|$){3}((?:[0-9]|$)|(?:[1-9]|$)(?:[0-9]|$)|(?:1|$)(?:[0-9]|$){2}|(?:2|$)(?:[0-4]|$)(?:[0-9]|$)|(?:2|$)(?:5|$)(?:[0-5]|$)|$)|$)(((?:\/|$)((?:[1-9]|$)|(?:[1-2]|$)(?:[0-9]|$)|(?:3|$)(?:[0-2]|$)|$)|$)?|$)|(?:a|$)(?:n|$)(?:y|$)|(?:A|$)(?:N|$)(?:Y|$)|$)(?::|$)((?:[0-9]|$)|(?:[0-9]|$){2}|(?:[0-9]|$){3}|(?:[0-9]|$){4}|(?:[0-5]|$)(?:[0-9]|$){4}|(?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?:o|$)(?:n|$)(?:5|$)(?:0|$)(?:0|$)(?:-|$)(?:i|$)(?:s|$)(?:a|$)(?:k|$)(?:m|$)(?:p|$)|(?:N|$)(?:O|$)(?:N|$)(?:5|$)(?:0|$)(?:0|$)(?:-|$)(?:I|$)(?:S|$)(?:A|$)(?:K|$)(?:M|$)(?:P|$)|(?:n|$)(?:t|$)(?:p|$)|(?:N|$)(?:T|$)(?:P|$)|(?:p|$)(?:o|$)(?:p|$)(?:3|$)|(?:P|$)(?:O|$)(?:P|$)(?:3|$)|(?:s|$)(?:m|$)(?:t|$)(?:p|$)|(?:S|$)(?:M|$)(?:T|$)(?:P|$)|(?:s|$)(?:n|$)(?:m|$)(?:p|$)|(?:S|$)(?:N|$)(?:M|$)(?:P|$)|(?:s|$)(?:n|$)(?:m|$)(?:p|$)(?:t|$)(?:r|$)(?:a|$)(?:p|$)|(?:S|$)(?:N|$)(?:M|$)(?:P|$)(?:T|$)(?:R|$)(?:A|$)(?:P|$)|(?:s|$)(?:u|$)(?:n|$)(?:r|$)(?:p|$)(?:c|$)|(?:S|$)(?:U|$)(?:N|$)(?:R|$)(?:P|$)(?:C|$)|(?:s|$)(?:y|$)(?:s|$)(?:l|$)(?:o|$)(?:g|$)|(?:S|$)(?:Y|$)(?:S|$)(?:L|$)(?:O|$)(?:G|$)|(?:t|$)(?:a|$)(?:c|$)(?:a|$)(?:c|$)(?:s|$)|(?:T|$)(?:A|$)(?:C|$)(?:A|$)(?:C|$)(?:S|$)|(?:t|$)(?:e|$)(?:l|$)(?:n|$)(?:e|$)(?:t|$)|(?:T|$)(?:E|$)(?:L|$)(?:N|$)(?:E|$)(?:T|$)|(?:t|$)(?:f|$)(?:t|$)(?:p|$)|(?:T|$)(?:F|$)(?:T|$)(?:P|$)|(?:w|$)(?:w|$)(?:w|$)|(?:W|$)(?:W|$)(?:W|$)|$)|$){2}|$)*

That's even longer than your original regexp, I still think that's what's causing the hang. As a matter of fact, I can eliminate the hang by redefining _computeRegexp() to just return this.pattern.

I don't know of any better solution to the problem so I'm closing this ticket as wontfix, but you can certainly use that workaround. It just means that you won't have validation as you type.

Changed 3 years ago by bill

working version of code, using workaround

Note: See TracTickets for help on using tickets.