guillaumepotier / Parsley.js

Validate your forms, frontend, without writing a single line of javascript

Home Page:http://parsleyjs.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Parsley accepts tld's with single character

opened this issue · comments

What kind of issue is this? (put 'x' between the square brackets)

example: https://codepen.io/henzestplus/pen/BaBxoJK?editors=101#anon-signup
topleveldomains are at least 2 characters, I am using sendinblue, and they seem to deny e-mail addresses with a single topleveldomain character.

parsley@parsley.c should fail, while parsley@parsley.co even though it might not exist, should succeed.Instead, both succeed.

Here is a replacement email address validator I had to create for my project that fixes that problem for the meantime.

// Parsley's email validator allows 1 character for the TLD (after the final dot) while the correct minimum is 2 characters
// this validator (data-parsley-real-email) uses a corrected version of Parsley's built-in RE
window.Parsley.addValidator('realEmail', {
  requirementType: 'string',
  validateString: function(value) {
    return /^((([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-zA-Z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]){2}|(([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-zA-Z]|\d|-|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-zA-Z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))$/.test(value);
  },
  priority: 256
});

I pushed a fix but now my test environment is broken. I don't know when I'll have the time to shave that yak...

Yak shaved, fix released a while back.

Thanks for the report 👍