Browse Source

Fix error in mask-lexer for regex \\w #2570

Robin Herbots 4 years ago
parent
commit
3abb248c79
9 changed files with 28 additions and 30 deletions
  1. 2 0
      CHANGELOG.md
  2. 1 1
      bower.json
  3. 1 1
      composer.json
  4. 2 2
      dist/inputmask.js
  5. 2 2
      dist/inputmask.min.js
  6. 2 2
      dist/jquery.inputmask.js
  7. 2 2
      dist/jquery.inputmask.min.js
  8. 15 19
      lib/mask-lexer.js
  9. 1 1
      package.json

+ 2 - 0
CHANGELOG.md

@@ -12,11 +12,13 @@
 - add casing definition option to the readme
 
 ### Updates
+- fix error in mask-lexer for \\w in regex
 - currency alias: add character substitution for the radixpoint
 - alias \\d to [0-9] in regex masks
 - clear masktemplate before submitting regardsless of the clearMaskOnLostFocus option
 
 ### Fixed
+- Uncaught InternalError: too much recursion freezes the browser #2570 (Regex issue)
 - Different behaviour configuration by attribute vs initialization #2530
 - The requested module './inputmask.js' does not provide an export named 'default' #2560
 - Issue with leapday #2546

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.7-beta.34",
+  "version": "5.0.7-beta.35",
   "main": [
 	  "./index.js",
     "./css/inputmask.css"

+ 1 - 1
composer.json

@@ -1,7 +1,7 @@
 {
   "name": "robinherbots/inputmask",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
-  "version": "5.0.7-beta.34",
+  "version": "5.0.7-beta.35",
   "type": "library",
   "keywords": ["jquery", "plugins", "input", "form", "inputmask", "mask"],
   "homepage": "http://robinherbots.github.io/Inputmask",

+ 2 - 2
dist/inputmask.js

@@ -3,7 +3,7 @@
  * https://github.com/RobinHerbots/Inputmask
  * Copyright (c) 2010 - 2021 Robin Herbots
  * Licensed under the MIT license
- * Version: 5.0.7-beta.34
+ * Version: 5.0.7-beta.35
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(); else if ("function" == typeof define && define.amd) define([], t); else {
@@ -1930,7 +1930,7 @@
                     function k(e, a, n) {
                         n = void 0 !== n ? n : e.matches.length;
                         var o = e.matches[n - 1];
-                        if (t) 0 === a.indexOf("[") || p && /\\d|\\s|\\w]/i.test(a) || "." === a ? e.matches.splice(n++, 0, {
+                        if (t) 0 === a.indexOf("[") || p && /\\d|\\s|\\w/i.test(a) || "." === a ? e.matches.splice(n++, 0, {
                             fn: new RegExp(a, i.casing ? "i" : ""),
                             static: !1,
                             optionality: !1,

File diff suppressed because it is too large
+ 2 - 2
dist/inputmask.min.js


+ 2 - 2
dist/jquery.inputmask.js

@@ -3,7 +3,7 @@
  * https://github.com/RobinHerbots/Inputmask
  * Copyright (c) 2010 - 2021 Robin Herbots
  * Licensed under the MIT license
- * Version: 5.0.7-beta.34
+ * Version: 5.0.7-beta.35
  */
 !function(e, t) {
     if ("object" == typeof exports && "object" == typeof module) module.exports = t(require("jquery")); else if ("function" == typeof define && define.amd) define([ "jquery" ], t); else {
@@ -1872,7 +1872,7 @@
                     function k(e, a, n) {
                         n = void 0 !== n ? n : e.matches.length;
                         var o = e.matches[n - 1];
-                        if (t) 0 === a.indexOf("[") || p && /\\d|\\s|\\w]/i.test(a) || "." === a ? e.matches.splice(n++, 0, {
+                        if (t) 0 === a.indexOf("[") || p && /\\d|\\s|\\w/i.test(a) || "." === a ? e.matches.splice(n++, 0, {
                             fn: new RegExp(a, i.casing ? "i" : ""),
                             static: !1,
                             optionality: !1,

File diff suppressed because it is too large
+ 2 - 2
dist/jquery.inputmask.min.js


+ 15 - 19
lib/mask-lexer.js

@@ -2,7 +2,7 @@ import $ from "./dependencyLibs/inputmask.dependencyLib";
 import MaskToken from "./masktoken";
 import Inputmask from "./inputmask";
 
-export {generateMaskSet, analyseMask};
+export { generateMaskSet, analyseMask };
 
 function generateMaskSet(opts, nocache) {
 	var ms;
@@ -115,7 +115,7 @@ function analyseMask(mask, regexMask, opts) {
 		position = position !== undefined ? position : mtoken.matches.length;
 		var prevMatch = mtoken.matches[position - 1];
 		if (regexMask) {
-			if (element.indexOf("[") === 0 || (escaped && /\\d|\\s|\\w]/i.test(element)) || element === ".") {
+			if (element.indexOf("[") === 0 || (escaped && /\\d|\\s|\\w/i.test(element)) || element === ".") {
 				mtoken.matches.splice(position++, 0, {
 					fn: new RegExp(element, opts.casing ? "i" : ""),
 					static: false,
@@ -323,6 +323,18 @@ function analyseMask(mask, regexMask, opts) {
 				case "\\d":
 					m = "[0-9]";
 					break;
+				case "(?=": //lookahead
+					// openenings.push(new MaskToken(true));
+					break;
+				case "(?!": //negative lookahead
+					// openenings.push(new MaskToken(true));
+					break;
+				case "(?<=": //lookbehind
+					// openenings.push(new MaskToken(true));
+					break;
+				case "(?<!": //negative lookbehind
+					// openenings.push(new MaskToken(true));
+					break;
 			}
 		}
 
@@ -330,20 +342,6 @@ function analyseMask(mask, regexMask, opts) {
 			defaultCase();
 			continue;
 		}
-		switch (m) {
-			case "(?=": //lookahead
-				// openenings.push(new MaskToken(true));
-				break;
-			case "(?!": //negative lookahead
-				// openenings.push(new MaskToken(true));
-				break;
-			case "(?<=": //lookbehind
-				// openenings.push(new MaskToken(true));
-				break;
-			case "(?<!": //negative lookbehind
-				// openenings.push(new MaskToken(true));
-				break;
-		}
 		switch (m.charAt(0)) {
 			case "$":
 			case "^":
@@ -354,9 +352,7 @@ function analyseMask(mask, regexMask, opts) {
 				break;
 			case opts.escapeChar:
 				escaped = true;
-				if (regexMask) {
-					defaultCase();
-				}
+				if (regexMask) defaultCase();
 				break;
 			// optional closing
 			case opts.optionalmarker[1]:

+ 1 - 1
package.json

@@ -1,6 +1,6 @@
 {
   "name": "inputmask",
-  "version": "5.0.7-beta.34",
+  "version": "5.0.7-beta.35",
   "description": "Inputmask is a javascript library which creates an input mask.  Inputmask can run against vanilla javascript, jQuery and jqlite.",
   "main": "dist/inputmask.js",
   "files": [