From 1c4f409aef4930040753ab59b5532b7e430f37cc Mon Sep 17 00:00:00 2001
From: Kieran Brahney
Date: Fri, 1 Jul 2022 16:20:23 +0100
Subject: [PATCH 01/32] Build: Updating the master version to 1.19.6-pre.
---
package.json | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/package.json b/package.json
index 0bc214db1..2cc35a6bc 100644
--- a/package.json
+++ b/package.json
@@ -2,7 +2,7 @@
"name": "jquery-validation",
"title": "jQuery Validation Plugin",
"description": "Client-side form validation made easy",
- "version": "1.19.5-pre",
+ "version": "1.19.6-pre",
"homepage": "https://jqueryvalidation.org/",
"license": "MIT",
"author": {
From 73c645d7d5f879543c32f03f5231200e3748fc30 Mon Sep 17 00:00:00 2001
From: Kieran Brahney
Date: Fri, 1 Jul 2022 16:30:42 +0100
Subject: [PATCH 02/32] Chore: update changelog
---
changelog.md | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/changelog.md b/changelog.md
index 284e5a15c..ca71122fb 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,3 +1,16 @@
+1.19.5 / 2022-06-01
+===================
+
+## Chore
+ * Add CodeQL analysis [3d3c1fb](https://github.com/jquery-validation/jquery-validation/commit/3d3c1fb880c3c623da334e9b6b32a861a16efeb8)
+
+## Core
+ * Fixed jQuery .submit() event shorthand deprecation notice [#2430](https://github.com/jquery-validation/jquery-validation/pull/2430)
+ * Fixed ReDos vulnerability in url, and url2 validation [5bbd80d](https://github.com/jquery-validation/jquery-validation/commit/5bbd80d27fc6b607d2f7f106c89522051a9fb0dd)
+
+## Localisation
+ * Added periods to messages [#2266](https://github.com/jquery-validation/jquery-validation/pull/2266)
+
1.19.4 / 2022-05-19
===================
@@ -28,7 +41,7 @@
* Add Accessibility section to Readme (#2149)
## Localization
- * Add "pattern" translation for French (#2363)
+ * Add "pattern" translation for French (#2363)
* add phone validate translate for Turkish translation (#2343)
1.19.2 / 2020-05-23
@@ -160,7 +173,7 @@ The hashes for the 1.19.0 release can be found in the file [`jquery-validation-s
## Tests
* Pass on the value of the used submit button for scripted submits (#2019)
* Use assert#pushResult instead of assert#push (#2018)
-
+
## All
* Fix links after move to organization
* Use https
From 24f2e277f1cb2c4d0dfcd97ae35997d43136dfbe Mon Sep 17 00:00:00 2001
From: Kieran
Date: Fri, 1 Jul 2022 21:39:27 +0100
Subject: [PATCH 03/32] Chore: correct 1.19.5 release date
---
changelog.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/changelog.md b/changelog.md
index ca71122fb..6bbbd5ccb 100644
--- a/changelog.md
+++ b/changelog.md
@@ -1,4 +1,4 @@
-1.19.5 / 2022-06-01
+1.19.5 / 2022-07-01
===================
## Chore
From 980087a897c1d3a03b87f8d07cf756e8b9bba6d5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sylvain=20Monn=C3=A9?=
Date: Fri, 15 Jul 2022 23:26:56 +0200
Subject: [PATCH 04/32] Core: fix race condition in remote validation rules
(#2435)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Fixes #2434
Co-authored-by: Sylvain Monné
---
src/ajax.js | 17 +++++++++++------
src/core.js | 27 ++++++++++++++++++++++++++-
test/methods.js | 30 ++++++++++++++++++++++++++++++
3 files changed, 67 insertions(+), 7 deletions(-)
diff --git a/src/ajax.js b/src/ajax.js
index fb56de4b3..5f87bed20 100644
--- a/src/ajax.js
+++ b/src/ajax.js
@@ -1,5 +1,6 @@
// Ajax mode: abort
// usage: $.ajax({ mode: "abort"[, port: "uniqueport"]});
+// $.ajaxAbort( port );
// if mode:"abort" is used, the previous request on that port (port can be undefined) is aborted via XMLHttpRequest.abort()
var pendingRequests = {},
@@ -10,9 +11,7 @@ if ( $.ajaxPrefilter ) {
$.ajaxPrefilter( function( settings, _, xhr ) {
var port = settings.port;
if ( settings.mode === "abort" ) {
- if ( pendingRequests[ port ] ) {
- pendingRequests[ port ].abort();
- }
+ $.ajaxAbort( port );
pendingRequests[ port ] = xhr;
}
} );
@@ -24,12 +23,18 @@ if ( $.ajaxPrefilter ) {
var mode = ( "mode" in settings ? settings : $.ajaxSettings ).mode,
port = ( "port" in settings ? settings : $.ajaxSettings ).port;
if ( mode === "abort" ) {
- if ( pendingRequests[ port ] ) {
- pendingRequests[ port ].abort();
- }
+ $.ajaxAbort( port );
pendingRequests[ port ] = ajax.apply( this, arguments );
return pendingRequests[ port ];
}
return ajax.apply( this, arguments );
};
}
+
+// Abort the previous request without sending a new one
+$.ajaxAbort = function( port ) {
+ if ( pendingRequests[ port ] ) {
+ pendingRequests[ port ].abort();
+ delete pendingRequests[ port ];
+ }
+};
diff --git a/src/core.js b/src/core.js
index ddb258119..923b3012b 100644
--- a/src/core.js
+++ b/src/core.js
@@ -756,6 +756,9 @@ $.extend( $.validator, {
val = this.elementValue( element ),
result, method, rule, normalizer;
+ // Abort any pending Ajax request from a previous call to this method.
+ this.abortRequest( element );
+
// Prioritize the local normalizer defined for this element over the global one
// if the former exists, otherwise user the global one in case it exists.
if ( typeof rules.normalizer === "function" ) {
@@ -1095,6 +1098,10 @@ $.extend( $.validator, {
return !$.validator.methods.required.call( this, val, element ) && "dependency-mismatch";
},
+ elementAjaxPort: function( element ) {
+ return "validate" + element.name;
+ },
+
startRequest: function( element ) {
if ( !this.pending[ element.name ] ) {
this.pendingRequest++;
@@ -1130,6 +1137,24 @@ $.extend( $.validator, {
}
},
+ abortRequest: function( element ) {
+ var port;
+
+ if ( this.pending[ element.name ] ) {
+ port = this.elementAjaxPort( element );
+ $.ajaxAbort( port );
+
+ this.pendingRequest--;
+
+ // Sometimes synchronization fails, make sure pendingRequest is never < 0
+ if ( this.pendingRequest < 0 ) {
+ this.pendingRequest = 0;
+ }
+
+ delete this.pending[ element.name ];
+ }
+ },
+
previousValue: function( element, method ) {
method = typeof method === "string" && method || "remote";
@@ -1570,7 +1595,7 @@ $.extend( $.validator, {
data[ element.name ] = value;
$.ajax( $.extend( true, {
mode: "abort",
- port: "validate" + element.name,
+ port: this.elementAjaxPort( element ),
dataType: "json",
data: data,
context: validator.currentForm,
diff --git a/test/methods.js b/test/methods.js
index fa49939e4..2966ec25f 100644
--- a/test/methods.js
+++ b/test/methods.js
@@ -801,6 +801,36 @@ QUnit.test( "Fix #697: remote validation uses wrong error messages", function( a
} );
} );
+QUnit.test( "Fix #2434: race condition in remote validation rules", function( assert ) {
+ var e = $( "#username" ),
+ done1 = assert.async(),
+ v = $( "#userForm" ).validate( {
+ rules: {
+ username: {
+ required: true,
+ remote: {
+ url: "users.php"
+ }
+ }
+ },
+ messages: {
+ username: {
+ remote: $.validator.format( "{0} in use" )
+ }
+ }
+ } );
+
+ e.val( "Peter" );
+ v.element( e );
+
+ e.val( "" );
+ v.element( e );
+ setTimeout( function() {
+ assert.equal( v.errorList[ 0 ].message, "This field is required." );
+ done1();
+ } );
+} );
+
QUnit.module( "additional methods" );
QUnit.test( "phone (us)", function( assert ) {
From 98fbc5f4287b9e580be6c1404094e9ae31b4abb2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Sylvain=20Monn=C3=A9?=
Date: Sun, 17 Jul 2022 13:21:36 +0200
Subject: [PATCH 05/32] Core: remove pending class from fields with an aborted
request (#2436)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Ref #2434
Ref #2435
Co-authored-by: Sylvain Monné
---
src/core.js | 1 +
test/methods.js | 8 ++++++++
2 files changed, 9 insertions(+)
diff --git a/src/core.js b/src/core.js
index 923b3012b..b7c62c04c 100644
--- a/src/core.js
+++ b/src/core.js
@@ -1152,6 +1152,7 @@ $.extend( $.validator, {
}
delete this.pending[ element.name ];
+ $( element ).removeClass( this.settings.pendingClass );
}
},
diff --git a/test/methods.js b/test/methods.js
index 2966ec25f..a65e4b474 100644
--- a/test/methods.js
+++ b/test/methods.js
@@ -822,11 +822,19 @@ QUnit.test( "Fix #2434: race condition in remote validation rules", function( as
e.val( "Peter" );
v.element( e );
+ assert.equal( e.hasClass( "error" ), false, "Field 'username' should not have the error class" );
+ assert.equal( e.hasClass( "pending" ), true, "field 'username' should have the pending class" );
e.val( "" );
v.element( e );
+ assert.equal( v.errorList[ 0 ].message, "This field is required." );
+ assert.equal( e.hasClass( "error" ), true, "Field 'username' should have the error class" );
+ assert.equal( e.hasClass( "pending" ), false, "field 'username' should not have the pending class" );
+
setTimeout( function() {
assert.equal( v.errorList[ 0 ].message, "This field is required." );
+ assert.equal( e.hasClass( "error" ), true, "Field 'username' should have the error class" );
+ assert.equal( e.hasClass( "pending" ), false, "field 'username' should not have the pending class" );
done1();
} );
} );
From f1bb23544bb7a796402b763af115662651aa6dbd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Fl=C3=A1vio=20Monteiro?=
Date: Thu, 13 Oct 2022 06:36:37 -0300
Subject: [PATCH 06/32] Localization: Improve required translation in pt_BR
(#2445)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
"É requerido" although correct is weird in this context (it's much more used in formal settings for documents known as requerimentos) and too much of a literal translation. This change aims to improve user-friendliness in this particular message.
---
src/localization/messages_pt_BR.js | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/localization/messages_pt_BR.js b/src/localization/messages_pt_BR.js
index 996c844be..42cd4a6bd 100644
--- a/src/localization/messages_pt_BR.js
+++ b/src/localization/messages_pt_BR.js
@@ -6,7 +6,7 @@
$.extend( $.validator.messages, {
// Core
- required: "Este campo é requerido.",
+ required: "Este campo é obrigatório.",
remote: "Por favor, corrija este campo.",
email: "Por favor, forneça um endereço de email válido.",
url: "Por favor, forneça uma URL válida.",
From d46e86c1432f449959025b1c41e4cf16eb62a699 Mon Sep 17 00:00:00 2001
From: Jonathan
Date: Fri, 11 Nov 2022 11:40:48 +0100
Subject: [PATCH 07/32] Demo: fix minlength validation in
ajaxSubmit-integration-demo.html (#2454)
---
demo/ajaxSubmit-integration-demo.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/demo/ajaxSubmit-integration-demo.html b/demo/ajaxSubmit-integration-demo.html
index 057f18dbe..21a7d38d9 100644
--- a/demo/ajaxSubmit-integration-demo.html
+++ b/demo/ajaxSubmit-integration-demo.html
@@ -74,7 +74,7 @@
-
+
From 29fb609cd093a7b5eca9ed33668b55765a4fc0b0 Mon Sep 17 00:00:00 2001
From: Saurabh <41580629+saurabhsharma2u@users.noreply.github.com>
Date: Fri, 11 Nov 2022 21:59:31 +0530
Subject: [PATCH 08/32] Localization: Add Hindi translation (#2453)
* Localisation: Update Hindi (India) translation
* Hindi Translation for Step Method
* HIndi-India Local messages for additional method
* file rename as per ISO 639-1 format
* removed duplicate message, causing the test fail
* removed duplicate "cifES" error message
---
src/localization/message_hi.js | 42 ++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
create mode 100644 src/localization/message_hi.js
diff --git a/src/localization/message_hi.js b/src/localization/message_hi.js
new file mode 100644
index 000000000..72bf4a149
--- /dev/null
+++ b/src/localization/message_hi.js
@@ -0,0 +1,42 @@
+/*
+ * Translated default messages for the jQuery validation plugin.
+ * Locale: Hindi; हिंदी
+ */
+$.extend( $.validator.messages, {
+ required: "आवश्यक फ़ील्ड।",
+ remote:"इस फ़ील्ड को जांचें।",
+ email: "एक वैध ई - मेल पते की प्रविष्टि करें।",
+ url: "कृपया एक वैध वेब पता दर्ज करें।",
+ date: "कृपया कोई मान्य दिनांक दर्ज करें।",
+ dateISO: "कृपया एक मान्य दिनांक (ISO) दर्ज करें।",
+ number: "कृपया सही अंक दर्ज करें।",
+ digits: "केवल संख्याएं दर्ज करें।",
+ creditcard: "कृपया एक वैध क्रेडिट कार्ड नंबर डालें।",
+ equalTo: "मेल नहीं खाता।",
+ extension: "कृपया एक मान्य एक्सटेंशन वाला मान दर्ज करें।",
+ maxlength: $.validator.format( "अधिक दर्ज न करें {0} वर्णों में से" ),
+ minlength: $.validator.format( "कृपया कम से कम {0} वर्ण दर्ज करें।" ),
+ rangelength: $.validator.format( "कृपया {0} और {1} वर्णों के बीच एक मान दर्ज करें।" ),
+ range: $.validator.format( "कृपया {0} और {1} के बीच एक मान दर्ज करें।" ),
+ max: $.validator.format( "कृपया {0} से कम या उसके बराबर मान दर्ज करें।" ),
+ min: $.validator.format( "कृपया {0} से अधिक या उसके बराबर मान दर्ज करें।" ),
+ nieES: "कृपया एक मान्य NIE दर्ज करें।",
+ cifES: "कृपया एक मान्य CIF दर्ज करें.",
+ currency: "कृपया एक मान्य मुद्रा दर्ज करें।.",
+ step: $.validator.format( "{0} का गुणज होना चाहिए।" ),
+ abaRoutingNumber:"कृपया एक मान्य रूटिंग नंबर दर्ज करें।",
+ accept:"कृपया एक मान्य माइमटाइप वाला मान दर्ज करें।",
+ alphanumeric:"कृपया, केवल अक्षर, संख्याएं और अंडरस्कोर।",
+ bankaccountNL:"कृपया एक वैध बैंक खाता संख्या निर्दिष्ट करें।",
+ bankorgiroaccountNL:"कृपया एक वैध बैंक या जीरो खाता संख्या निर्दिष्ट करें।",
+ bic:"कृपया कोई मान्य BIC कोड निर्दिष्ट करें।",
+ ziprange:"आपका ज़िप कोड 902xx-xxxx से 905xx-xxxx की सीमा में होना चाहिए।",
+ zipcodeUS:"निर्दिष्ट यूएस ज़िप कोड अमान्य है।",
+ vinUS:"निर्दिष्ट वाहन पहचान संख्या (VIN) अमान्य है।",
+ time12h:"कृपया 12 घंटे पूर्वाह्न/अपराह्न प्रारूप में मान्य समय दर्ज करें।",
+ time:"कृपया 00:00 और 23:59 के बीच एक वैध समय दर्ज करें।",
+ strippedminlength:"कृपया कम से कम {0} वर्ण दर्ज करें।",
+ stateUS:"कृपया एक वैध प्रदेश निर्दिष्ट करें।",
+ skip_or_fill_minimum:"कृपया या तो इन फ़ील्ड को छोड़ दें या उनमें से कम से कम {0} भरें।",
+ require_from_group:"कृपया इनमें से कम से कम {0} को भरें।"
+} );
From 13b859e35735086cb320423b3585d8a6edee4349 Mon Sep 17 00:00:00 2001
From: Warren White <111083379+wewhite@users.noreply.github.com>
Date: Thu, 1 Dec 2022 02:50:24 -0800
Subject: [PATCH 09/32] Additional: vinUS validation fails on valid vin numbers
(#2460)
* Removed === compare, changed to ==
Compare by value and type (===) does not work for this algorithm, as both cd and cdv can be either types at the same time.
By comparing by value only (==) cd and cdv can be either integer or string, as a string number will be converted to a number reqardless of type.
* Rewrote forloop, removed nested forloop
* Additional: fixed spacing issues
* Additional: Add vinUS.js validation test cases
Test cases include default test with 17 one's, and additional US and Canada VIN
* Additional: add two more test casses for vinUS
* Additional: removed text license number, should be VIN
---
src/additional/vinUS.js | 69 ++++++++++++++++++----------------------
test/additional/vinUS.js | 11 +++++++
test/index.html | 1 +
3 files changed, 43 insertions(+), 38 deletions(-)
create mode 100644 test/additional/vinUS.js
diff --git a/src/additional/vinUS.js b/src/additional/vinUS.js
index 15460d725..3fd2d128b 100644
--- a/src/additional/vinUS.js
+++ b/src/additional/vinUS.js
@@ -11,44 +11,37 @@
* @cat Plugins/Validate/Methods
*/
$.validator.addMethod( "vinUS", function( v ) {
- if ( v.length !== 17 ) {
- return false;
- }
+ if ( v.length !== 17 ) {
+ return false;
+ }
- var LL = [ "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" ],
- VL = [ 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 7, 9, 2, 3, 4, 5, 6, 7, 8, 9 ],
- FL = [ 8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2 ],
- rs = 0,
- i, n, d, f, cd, cdv;
+ var LL = [ "A", "B", "C", "D", "E", "F", "G", "H", "J", "K", "L", "M", "N", "P", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" ],
+ VL = [ 1, 2, 3, 4, 5, 6, 7, 8, 1, 2, 3, 4, 5, 7, 9, 2, 3, 4, 5, 6, 7, 8, 9 ],
+ FL = [ 8, 7, 6, 5, 4, 3, 2, 10, 0, 9, 8, 7, 6, 5, 4, 3, 2 ],
+ rs = 0,
+ i, n, d, f, cd, cdv;
- for ( i = 0; i < 17; i++ ) {
- f = FL[ i ];
- d = v.slice( i, i + 1 );
- if ( i === 8 ) {
- cdv = d;
- }
- if ( !isNaN( d ) ) {
- d *= f;
- } else {
- for ( n = 0; n < LL.length; n++ ) {
- if ( d.toUpperCase() === LL[ n ] ) {
- d = VL[ n ];
- d *= f;
- if ( isNaN( cdv ) && n === 8 ) {
- cdv = LL[ n ];
- }
- break;
- }
- }
- }
- rs += d;
- }
- cd = rs % 11;
- if ( cd === 10 ) {
- cd = "X";
- }
- if ( cd === cdv ) {
- return true;
- }
- return false;
+ for ( i = 0; i < 17; i++ ) {
+ f = FL[ i ];
+ d = v.slice( i, i + 1 );
+ if ( isNaN( d ) ) {
+ d = d.toUpperCase();
+ n = VL[ LL.indexOf( d ) ];
+ } else {
+ n = parseInt( d, 10 );
+ }
+ if ( i === 8 )
+ {
+ cdv = n;
+ if ( d === "X" ) {
+ cdv = 10;
+ }
+ }
+ rs += n * f;
+ }
+ cd = rs % 11;
+ if ( cd === cdv ) {
+ return true;
+ }
+ return false;
}, "The specified vehicle identification number (VIN) is invalid." );
diff --git a/test/additional/vinUS.js b/test/additional/vinUS.js
new file mode 100644
index 000000000..3311b0111
--- /dev/null
+++ b/test/additional/vinUS.js
@@ -0,0 +1,11 @@
+QUnit.test( "vinUS", function( assert ) {
+ var method = methodTest( "vinUS" );
+ assert.ok( method( "11111111111111111" ), "Valid test VIN number" );
+ assert.ok( method( "1FTFX1CT9CFD06231" ), "Valid US VIN number" );
+ assert.ok( method( "2FTHF26F8SCA68695" ), "Valid CAN VIN number" );
+ assert.ok( method( "LJCPCBLCX11000237" ), "Valid VIN with X check digit" );
+ assert.ok( !method( "LJCPCBLC011000237" ), "Invalid VIN with 0 check digit" );
+ assert.ok( !method( "2FTHF26F8" ), "InValid VIN number" );
+ assert.ok( !method( "11111111X1111111" ), "Invalid test VIN" );
+ assert.ok( !method( "1111111101111111" ), "Invalid test VIN" );
+} );
diff --git a/test/index.html b/test/index.html
index bf22a640a..17c6438b8 100644
--- a/test/index.html
+++ b/test/index.html
@@ -19,6 +19,7 @@
+
From cfe74a19b671b0983b3b13dbf959619cfe926de9 Mon Sep 17 00:00:00 2001
From: Leonardo Spina
Date: Tue, 24 Jan 2023 11:37:07 +0000
Subject: [PATCH 10/32] Core: Call to resetInternals removed in remote
validation callback (#2242)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
* Core: Call to resetInternals removed in remote validation callback
* Core: Add unit test for issue #2150 fix
* Core: fix code style errors
Co-authored-by: leonardospina
Co-authored-by: Julien Tschäppät
---
src/core.js | 1 -
test/index.html | 4 ++++
test/test.js | 31 +++++++++++++++++++++++++++++++
3 files changed, 35 insertions(+), 1 deletion(-)
diff --git a/src/core.js b/src/core.js
index b7c62c04c..5a2fb1ce4 100644
--- a/src/core.js
+++ b/src/core.js
@@ -1607,7 +1607,6 @@ $.extend( $.validator, {
validator.settings.messages[ element.name ][ method ] = previous.originalMessage;
if ( valid ) {
submitted = validator.formSubmitted;
- validator.resetInternals();
validator.toHide = validator.errorsFor( element );
validator.formSubmitted = submitted;
validator.successList.push( element );
diff --git a/test/index.html b/test/index.html
index 17c6438b8..f27ad1d76 100644
--- a/test/index.html
+++ b/test/index.html
@@ -72,6 +72,10 @@
+