ソースを参照

#612, #740, #741: Fix the issue which email@server is not valid email address, thanks to @kromit

phuoc 11 年 前
コミット
62ca6d58ef

+ 1 - 0
CHANGELOG.md

@@ -18,6 +18,7 @@ __Improvements__
 
 __Bug Fixes__
 * [#611](https://github.com/nghuuphuoc/bootstrapvalidator/issues/611), [#703](https://github.com/nghuuphuoc/bootstrapvalidator/issues/703): Tabs get red even form is valid
+* [#612](https://github.com/nghuuphuoc/bootstrapvalidator/issues/612), [#740](https://github.com/nghuuphuoc/bootstrapvalidator/pull/740), [#741](https://github.com/nghuuphuoc/bootstrapvalidator/pull/741): Fix the [emailAddress](http://bootstrapvalidator.com/validators/emailAddress/) issue which email@server is not valid email address, thanks to [@kromit](https://github.com/kromit)
 * [#687](https://github.com/nghuuphuoc/bootstrapvalidator/issues/687), [#711](https://github.com/nghuuphuoc/bootstrapvalidator/pull/711): Keep disabled validators VALID, thanks to [@talberti](https://github.com/talberti)
 * [#725](https://github.com/nghuuphuoc/bootstrapvalidator/pull/725): Fix the issue when adding field which does not exist but is already set in "fields" option
 * [#732](https://github.com/nghuuphuoc/bootstrapvalidator/issues/732): Fix the issue when removing the radio or checkbox field

+ 1 - 0
CONTRIBUTORS.md

@@ -40,6 +40,7 @@ I would like to give big thanks to the following contributors:
 * [@kenny-evitt](https://github.com/kenny-evitt)
 * [@khangvm53](https://github.com/khangvm53)
 * [@kristian-puccio](https://github.com/kristian-puccio)
+* [@kromit](https://github.com/kromit)
 * [@leegtang](https://github.com/leegtang)
 * [@lloydde](https://github.com/lloydde)
 * [@logemann](https://github.com/logemann)

+ 1 - 1
dist/css/bootstrapValidator.min.css

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.2-dev, built on 2014-08-29 4:10:46 PM
+ * @version     v0.5.2-dev, built on 2014-08-29 7:03:30 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT

+ 2 - 2
dist/js/bootstrapValidator.js

@@ -2,7 +2,7 @@
  * BootstrapValidator (http://bootstrapvalidator.com)
  * The best jQuery plugin to validate form fields. Designed to use with Bootstrap 3
  *
- * @version     v0.5.2-dev, built on 2014-08-29 4:10:46 PM
+ * @version     v0.5.2-dev, built on 2014-08-29 7:03:30 PM
  * @author      https://twitter.com/nghuuphuoc
  * @copyright   (c) 2013 - 2014 Nguyen Huu Phuoc
  * @license     MIT
@@ -2677,7 +2677,7 @@
 
             // Email address regular expression
             // http://stackoverflow.com/questions/46155/validate-email-address-in-javascript
-            var emailRegExp   = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/,
+            var emailRegExp   = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/,
                 allowMultiple = options.multiple === true || options.multiple === 'true';
 
             if (allowMultiple) {

ファイルの差分が大きいため隠しています
+ 2 - 2
dist/js/bootstrapValidator.min.js


+ 19 - 19
test/spec.js

@@ -510,7 +510,7 @@ describe('event form attribute callback global', function() {
     });
 
     it('call data-bv-onerror', function() {
-        this.$email.val('email@domain');
+        this.$email.val('a@b@c@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('form eventForm is invalid');
     });
@@ -544,7 +544,7 @@ describe('event form attribute callback namespace', function() {
     });
 
     it('call data-bv-onerror', function() {
-        this.$email.val('email@domain');
+        this.$email.val('just"not"right@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('TestSuite.Event.onFormInvalid() called, form eventForm is invalid');
     });
@@ -585,7 +585,7 @@ describe('event form trigger', function() {
     });
 
     it('trigger error.form.bv', function() {
-        this.$email.val('email@domain');
+        this.$email.val('this is"not\\allowed@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('form eventForm triggered error.form.bv event');
     });
@@ -626,7 +626,7 @@ describe('event form programmatically', function() {
     });
 
     it('call onError()', function() {
-        this.$email.val('email@domain');
+        this.$email.val('Abc.example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('onError() called');
     });
@@ -678,7 +678,7 @@ describe('event field attribute callback global', function() {
     });
 
     it('call data-bv-onerror', function() {
-        this.$email.val('email@domain');
+        this.$email.val('A@b@c@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('email is invalid');
         expect($('#status').html()).toEqual(this.bv.STATUS_INVALID);
@@ -715,7 +715,7 @@ describe('event field attribute callback namespace', function() {
     });
 
     it('call data-bv-onerror', function() {
-        this.$email.val('email@domain');
+        this.$email.val('a"b(c)d,e:f;gi[j\\k]l@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('TestSuite.Event.onEmailInvalid() called, email is invalid');
         expect($('#status').html()).toEqual('TestSuite.Event.onEmailStatus() called; status = ' + this.bv.STATUS_INVALID);
@@ -757,7 +757,7 @@ describe('event field trigger', function() {
     });
 
     it('trigger error.field.bv', function() {
-        this.$email.val('email@domain');
+        this.$email.val('just"not"right@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('triggered error.field.bv on email');
     });
@@ -802,7 +802,7 @@ describe('event field programmatically', function() {
     });
 
     it('call onError()', function() {
-        this.$email.val('email@domain');
+        this.$email.val('this is"not\\allowed@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('onError() called');
     });
@@ -859,13 +859,13 @@ describe('event form trigger with default events', function() {
     });
 
     it('does not trigger bv.form.error', function() {
-        this.$email.val('email@domain');
+        this.$email.val('A@b@c@example.com');
         this.bv.validate();
         expect($('#msg').html()).not.toEqual('form eventForm1 triggered bv.form.error event');
     });
 
     it('triggers error.form.bv', function() {
-        this.$email.val('email@domain');
+        this.$email.val('A@b@c@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('form eventForm1 triggered error.form.bv event');
     });
@@ -918,13 +918,13 @@ describe('event field trigger with default events', function() {
     });
 
     it('does not trigger error.field.bv', function() {
-        this.$email.val('email@domain');
+        this.$email.val('just"not"right@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('triggered error.field.bv on email');
     });
 
     it('triggers bv.field.error', function() {
-        this.$email.val('email@domain');
+        this.$email.val('just"not"right@example.com');
         this.bv.validate();
         expect($('#msg').html()).not.toEqual('triggered bv.field.error on email');
     });
@@ -995,7 +995,7 @@ describe('event form trigger with events changed', function() {
     it('triggers bv.form.error', function() {
         spyOn(window, 'onerror');
 
-        this.$email.val('email@domain');
+        this.$email.val('this is"not\\allowed@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('form eventForm2 triggered bv.form.error event');
 
@@ -1066,7 +1066,7 @@ describe('event field trigger with events changed', function() {
     });
 
     it('does not trigger error.field.bv', function() {
-        this.$email.val('email@domain');
+        this.$email.val('Abc.example.com');
         this.bv.validate();
         expect($('#msg').html()).not.toEqual('triggered error.field.bv on email');
     });
@@ -1074,7 +1074,7 @@ describe('event field trigger with events changed', function() {
     it('triggers bv.field.error', function() {
         spyOn(window, 'onerror');
 
-        this.$email.val('email@domain');
+        this.$email.val('Abc.example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('triggered bv.field.error on email');
 
@@ -1122,7 +1122,7 @@ describe('event validator declarative', function() {
     });
 
     it('trigger data-bv-emailaddress-onerror', function() {
-        this.$email.val('email@domain');
+        this.$email.val('A@b@c@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('emailAddress validator did not pass');
     });
@@ -1172,7 +1172,7 @@ describe('event validator programmatically', function() {
     });
 
     it('call onError()', function() {
-        this.$email.val('email@domain');
+        this.$email.val('A@b@c@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('emailAddress validator: onError() called');
     });
@@ -1714,7 +1714,7 @@ describe('i18n', function() {
         expect(this.bv.getMessages('username', 'different')[0]).toEqual(i18n.different['default']);
 
         this.bv.resetForm();
-        this.$email.val('invalid#email@address');
+        this.$email.val('A@b@c@example.com');
         this.bv.validate();
         expect(this.bv.getMessages(this.$email, 'emailAddress')[0]).toEqual(i18n.emailAddress['default']);
 
@@ -2615,6 +2615,7 @@ describe('emailAddress', function() {
     });
 
     var validEmailAddresses = [
+        'admin@mailserver1',
         'niceandsimple@example.com',
         'very.common@example.com',
         'a.little.lengthy.but.fine@dept.example.com',
@@ -2628,7 +2629,6 @@ describe('emailAddress', function() {
     ];
 
     var invalidEmailAddresses = [
-        'admin@mailserver1',
         // "!#$%&'*+-/=?^_`{}|~@example.org",   // This is actually passing validation; see https://github.com/nghuuphuoc/bootstrapvalidator/issues/673
         'üñîçøðé@üñîçøðé.com',
         'Abc.example.com',

+ 17 - 17
test/spec/event.js

@@ -62,7 +62,7 @@ describe('event form attribute callback global', function() {
     });
 
     it('call data-bv-onerror', function() {
-        this.$email.val('email@domain');
+        this.$email.val('a@b@c@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('form eventForm is invalid');
     });
@@ -96,7 +96,7 @@ describe('event form attribute callback namespace', function() {
     });
 
     it('call data-bv-onerror', function() {
-        this.$email.val('email@domain');
+        this.$email.val('just"not"right@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('TestSuite.Event.onFormInvalid() called, form eventForm is invalid');
     });
@@ -137,7 +137,7 @@ describe('event form trigger', function() {
     });
 
     it('trigger error.form.bv', function() {
-        this.$email.val('email@domain');
+        this.$email.val('this is"not\\allowed@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('form eventForm triggered error.form.bv event');
     });
@@ -178,7 +178,7 @@ describe('event form programmatically', function() {
     });
 
     it('call onError()', function() {
-        this.$email.val('email@domain');
+        this.$email.val('Abc.example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('onError() called');
     });
@@ -230,7 +230,7 @@ describe('event field attribute callback global', function() {
     });
 
     it('call data-bv-onerror', function() {
-        this.$email.val('email@domain');
+        this.$email.val('A@b@c@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('email is invalid');
         expect($('#status').html()).toEqual(this.bv.STATUS_INVALID);
@@ -267,7 +267,7 @@ describe('event field attribute callback namespace', function() {
     });
 
     it('call data-bv-onerror', function() {
-        this.$email.val('email@domain');
+        this.$email.val('a"b(c)d,e:f;gi[j\\k]l@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('TestSuite.Event.onEmailInvalid() called, email is invalid');
         expect($('#status').html()).toEqual('TestSuite.Event.onEmailStatus() called; status = ' + this.bv.STATUS_INVALID);
@@ -309,7 +309,7 @@ describe('event field trigger', function() {
     });
 
     it('trigger error.field.bv', function() {
-        this.$email.val('email@domain');
+        this.$email.val('just"not"right@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('triggered error.field.bv on email');
     });
@@ -354,7 +354,7 @@ describe('event field programmatically', function() {
     });
 
     it('call onError()', function() {
-        this.$email.val('email@domain');
+        this.$email.val('this is"not\\allowed@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('onError() called');
     });
@@ -411,13 +411,13 @@ describe('event form trigger with default events', function() {
     });
 
     it('does not trigger bv.form.error', function() {
-        this.$email.val('email@domain');
+        this.$email.val('A@b@c@example.com');
         this.bv.validate();
         expect($('#msg').html()).not.toEqual('form eventForm1 triggered bv.form.error event');
     });
 
     it('triggers error.form.bv', function() {
-        this.$email.val('email@domain');
+        this.$email.val('A@b@c@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('form eventForm1 triggered error.form.bv event');
     });
@@ -470,13 +470,13 @@ describe('event field trigger with default events', function() {
     });
 
     it('does not trigger error.field.bv', function() {
-        this.$email.val('email@domain');
+        this.$email.val('just"not"right@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('triggered error.field.bv on email');
     });
 
     it('triggers bv.field.error', function() {
-        this.$email.val('email@domain');
+        this.$email.val('just"not"right@example.com');
         this.bv.validate();
         expect($('#msg').html()).not.toEqual('triggered bv.field.error on email');
     });
@@ -547,7 +547,7 @@ describe('event form trigger with events changed', function() {
     it('triggers bv.form.error', function() {
         spyOn(window, 'onerror');
 
-        this.$email.val('email@domain');
+        this.$email.val('this is"not\\allowed@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('form eventForm2 triggered bv.form.error event');
 
@@ -618,7 +618,7 @@ describe('event field trigger with events changed', function() {
     });
 
     it('does not trigger error.field.bv', function() {
-        this.$email.val('email@domain');
+        this.$email.val('Abc.example.com');
         this.bv.validate();
         expect($('#msg').html()).not.toEqual('triggered error.field.bv on email');
     });
@@ -626,7 +626,7 @@ describe('event field trigger with events changed', function() {
     it('triggers bv.field.error', function() {
         spyOn(window, 'onerror');
 
-        this.$email.val('email@domain');
+        this.$email.val('Abc.example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('triggered bv.field.error on email');
 
@@ -674,7 +674,7 @@ describe('event validator declarative', function() {
     });
 
     it('trigger data-bv-emailaddress-onerror', function() {
-        this.$email.val('email@domain');
+        this.$email.val('A@b@c@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('emailAddress validator did not pass');
     });
@@ -724,7 +724,7 @@ describe('event validator programmatically', function() {
     });
 
     it('call onError()', function() {
-        this.$email.val('email@domain');
+        this.$email.val('A@b@c@example.com');
         this.bv.validate();
         expect($('#msg').html()).toEqual('emailAddress validator: onError() called');
     });

+ 1 - 1
test/spec/i18n.js

@@ -275,7 +275,7 @@ describe('i18n', function() {
         expect(this.bv.getMessages('username', 'different')[0]).toEqual(i18n.different['default']);
 
         this.bv.resetForm();
-        this.$email.val('invalid#email@address');
+        this.$email.val('A@b@c@example.com');
         this.bv.validate();
         expect(this.bv.getMessages(this.$email, 'emailAddress')[0]).toEqual(i18n.emailAddress['default']);