Browse Source

fix infinite loop #415

Robin Herbots 12 years ago
parent
commit
3d8a613cc3

+ 1 - 1
bower.json

@@ -1,6 +1,6 @@
 {
 {
     "name": "jquery.inputmask",
     "name": "jquery.inputmask",
-    "version": "2.4.19",
+    "version": "2.4.20",
     "main": "./dist/jquery.inputmask.bundle.js",
     "main": "./dist/jquery.inputmask.bundle.js",
 	"keywords" : ["jQuery", "plugins", "input", "form", "inputmask", "mask"],
 	"keywords" : ["jQuery", "plugins", "input", "form", "inputmask", "mask"],
 	"description": "jquery.inputmask is a jquery plugin which create an input mask.",
 	"description": "jquery.inputmask is a jquery plugin which create an input mask.",

+ 1 - 1
build.properties

@@ -7,7 +7,7 @@ distdir = dist
 
 
 build.major = 2
 build.major = 2
 build.minor = 4
 build.minor = 4
-build.revision = 19
+build.revision = 20
 
 
 target = jquery.inputmask.bundle.js
 target = jquery.inputmask.bundle.js
 target.min = jquery.inputmask.bundle.min.js
 target.min = jquery.inputmask.bundle.min.js

BIN
dist/jQuery.InputMask.2.4.19.nupkg


BIN
dist/jQuery.InputMask.2.4.20.nupkg


+ 10 - 10
dist/jquery.inputmask.bundle.js

@@ -3,7 +3,7 @@
 * http://github.com/RobinHerbots/jquery.inputmask
 * http://github.com/RobinHerbots/jquery.inputmask
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Copyright (c) 2010 - 2014 Robin Herbots
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 * Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-* Version: 2.4.19
+* Version: 2.4.20
 */
 */
 
 
 (function ($) {
 (function ($) {
@@ -276,8 +276,8 @@
                     //return is false or a json object => { pos: ??, c: ??} or true
                     //return is false or a json object => { pos: ??, c: ??} or true
                     return activeMaskset['tests'][testPos].fn != null ?
                     return activeMaskset['tests'][testPos].fn != null ?
                         activeMaskset['tests'][testPos].fn.test(chrs, buffer, position, strict, opts)
                         activeMaskset['tests'][testPos].fn.test(chrs, buffer, position, strict, opts)
-                        : (c == getBufferElement(activeMaskset['_buffer'], position, true) || c == opts.skipOptionalPartCharacter) ?
-                            { "refresh": true, c: getBufferElement(activeMaskset['_buffer'], position, true), pos: position }
+                        : (c == getBufferElement(activeMaskset['_buffer'].slice(), position, true) || c == opts.skipOptionalPartCharacter) ?
+                            { "refresh": true, c: getBufferElement(activeMaskset['_buffer'].slice(), position, true), pos: position }
                             : false;
                             : false;
                 }
                 }
 
 
@@ -995,7 +995,7 @@
                         }
                         }
 
 
                         //should we clear a possible selection??
                         //should we clear a possible selection??
-                        var isSlctn = isSelection(pos.begin, pos.end), redetermineLVP = false,
+                        var isSlctn = isSelection(pos.begin, pos.end),
                             initialIndex = activeMasksetIndex;
                             initialIndex = activeMasksetIndex;
                         if (isSlctn) {
                         if (isSlctn) {
                             activeMasksetIndex = initialIndex;
                             activeMasksetIndex = initialIndex;
@@ -1056,7 +1056,7 @@
                                             shiftR(p, getMaskLength(), c);
                                             shiftR(p, getMaskLength(), c);
                                             //shift the lvp if needed
                                             //shift the lvp if needed
                                             var lvp = getActiveMaskSet()["lastValidPosition"], nlvp = seekNext(lvp);
                                             var lvp = getActiveMaskSet()["lastValidPosition"], nlvp = seekNext(lvp);
-                                            if (nlvp != getMaskLength() && lvp >= p && (getBufferElement(getActiveBuffer(), nlvp, true) != getPlaceHolder(nlvp))) {
+                                            if (nlvp != getMaskLength() && lvp >= p && (getBufferElement(getActiveBuffer().slice(), nlvp, true) != getPlaceHolder(nlvp))) {
                                                 getActiveMaskSet()["lastValidPosition"] = nlvp;
                                                 getActiveMaskSet()["lastValidPosition"] = nlvp;
                                             }
                                             }
                                         } else getActiveMaskSet()["writeOutBuffer"] = false;
                                         } else getActiveMaskSet()["writeOutBuffer"] = false;
@@ -1635,7 +1635,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.4.19
+Version: 2.4.20
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -1757,7 +1757,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.4.19
+Version: 2.4.20
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2245,7 +2245,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.4.19
+Version: 2.4.20
 
 
 Optional extensions on the jquery.inputmask base
 Optional extensions on the jquery.inputmask base
 */
 */
@@ -2422,7 +2422,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.4.19
+Version: 2.4.20
 
 
 Regex extensions on the jquery.inputmask base
 Regex extensions on the jquery.inputmask base
 Allows for using regular expressions as a mask
 Allows for using regular expressions as a mask
@@ -2592,7 +2592,7 @@ Input Mask plugin extensions
 http://github.com/RobinHerbots/jquery.inputmask
 http://github.com/RobinHerbots/jquery.inputmask
 Copyright (c) 2010 - 2014 Robin Herbots
 Copyright (c) 2010 - 2014 Robin Herbots
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
 Licensed under the MIT license (http://www.opensource.org/licenses/mit-license.php)
-Version: 2.4.19
+Version: 2.4.20
 
 
 Phone extension.
 Phone extension.
 When using this extension make sure you specify the correct url to get the masks
 When using this extension make sure you specify the correct url to get the masks

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


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


+ 1 - 1
jquery.inputmask.jquery.json

@@ -8,7 +8,7 @@
 		"inputmask",
 		"inputmask",
 		"mask"
 		"mask"
     ],
     ],
-    "version": "2.4.19",
+    "version": "2.4.20",
     "author": {
     "author": {
         "name": "Robin Herbots",
         "name": "Robin Herbots",
         "url": "http://github.com/RobinHerbots/jquery.inputmask"
         "url": "http://github.com/RobinHerbots/jquery.inputmask"

+ 4 - 4
js/jquery.inputmask.js

@@ -276,8 +276,8 @@
                     //return is false or a json object => { pos: ??, c: ??} or true
                     //return is false or a json object => { pos: ??, c: ??} or true
                     return activeMaskset['tests'][testPos].fn != null ?
                     return activeMaskset['tests'][testPos].fn != null ?
                         activeMaskset['tests'][testPos].fn.test(chrs, buffer, position, strict, opts)
                         activeMaskset['tests'][testPos].fn.test(chrs, buffer, position, strict, opts)
-                        : (c == getBufferElement(activeMaskset['_buffer'], position, true) || c == opts.skipOptionalPartCharacter) ?
-                            { "refresh": true, c: getBufferElement(activeMaskset['_buffer'], position, true), pos: position }
+                        : (c == getBufferElement(activeMaskset['_buffer'].slice(), position, true) || c == opts.skipOptionalPartCharacter) ?
+                            { "refresh": true, c: getBufferElement(activeMaskset['_buffer'].slice(), position, true), pos: position }
                             : false;
                             : false;
                 }
                 }
 
 
@@ -995,7 +995,7 @@
                         }
                         }
 
 
                         //should we clear a possible selection??
                         //should we clear a possible selection??
-                        var isSlctn = isSelection(pos.begin, pos.end), redetermineLVP = false,
+                        var isSlctn = isSelection(pos.begin, pos.end),
                             initialIndex = activeMasksetIndex;
                             initialIndex = activeMasksetIndex;
                         if (isSlctn) {
                         if (isSlctn) {
                             activeMasksetIndex = initialIndex;
                             activeMasksetIndex = initialIndex;
@@ -1056,7 +1056,7 @@
                                             shiftR(p, getMaskLength(), c);
                                             shiftR(p, getMaskLength(), c);
                                             //shift the lvp if needed
                                             //shift the lvp if needed
                                             var lvp = getActiveMaskSet()["lastValidPosition"], nlvp = seekNext(lvp);
                                             var lvp = getActiveMaskSet()["lastValidPosition"], nlvp = seekNext(lvp);
-                                            if (nlvp != getMaskLength() && lvp >= p && (getBufferElement(getActiveBuffer(), nlvp, true) != getPlaceHolder(nlvp))) {
+                                            if (nlvp != getMaskLength() && lvp >= p && (getBufferElement(getActiveBuffer().slice(), nlvp, true) != getPlaceHolder(nlvp))) {
                                                 getActiveMaskSet()["lastValidPosition"] = nlvp;
                                                 getActiveMaskSet()["lastValidPosition"] = nlvp;
                                             }
                                             }
                                         } else getActiveMaskSet()["writeOutBuffer"] = false;
                                         } else getActiveMaskSet()["writeOutBuffer"] = false;

+ 14 - 1
qunit/tests.js

@@ -337,12 +337,25 @@ test("inputmask(\"*\", { greedy: false, repeat: \"*\" }) - type abcdef", functio
     $("#testmask")[0].focus();
     $("#testmask")[0].focus();
 
 
     $("#testmask").Type("abcdef");
     $("#testmask").Type("abcdef");
-
+	
     equal($("#testmask").val(), "abcdef", "Result " + $("#testmask").val());
     equal($("#testmask").val(), "abcdef", "Result " + $("#testmask").val());
 
 
     $("#testmask").remove();
     $("#testmask").remove();
 });
 });
 
 
+test("inputmask(\"A.\", { repeat: \"*\" }) - type abc - joostburg", function () {
+    $('body').append('<input type="text" id="testmask" />');
+    $("#testmask").inputmask("A.", { repeat: "*" });
+
+    $("#testmask")[0].focus();
+
+    $("#testmask").Type("abc");
+
+    equal($("#testmask").val(), "A.B.C.", "Result " + $("#testmask").val());
+
+    $("#testmask").remove();
+});
+
 module("greedy masks");
 module("greedy masks");
 test("inputmask(\"*\", { greedy: true, repeat: 10, clearMaskOnLostFocus: false  })", function () {
 test("inputmask(\"*\", { greedy: true, repeat: 10, clearMaskOnLostFocus: false  })", function () {
     $('body').append('<input type="text" id="testmask" />');
     $('body').append('<input type="text" id="testmask" />');