Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

input type="email" validation does not allow more than 57 not-latin characters in domain part #15864

Closed
1 of 3 tasks
andrew-kuzovov opened this issue Mar 27, 2017 · 1 comment

Comments

@andrew-kuzovov
Copy link

andrew-kuzovov commented Mar 27, 2017

I'm submitting a ...

  • bug report
  • feature request
  • other (Please do not submit support requests here (see above))

Current behavior:

E-mails like "email@вввввввввввввввввввввввввввввввввввввввввввввввввввввввввв.com"
are considered invalid ("в" in domain here is russian symbol) when reaching length more than 57. Classes "ng-invalid", "ng-invalid-email" are set. But when latin symbols are used in domain - there is no such restriction.

Expected / new behavior:

E-mails like: email@вввввввввввввввввввввввввввввввввввввввввввввввввввввввввв.com
should be considered valid

Minimal reproduction of the problem with instructions:

Input email with more than 57 non-latin symbols in domain part, like "email@вввввввввввввввввввввввввввввввввввввввввввввввввввввввввв.com"

  <div ng-app="myapp">
<form>
     <input id="email"
            type="email"
            name="email"
            ng-model="email"
            placeholder="email"
            maxlength="255"
            ng-trim="false" />
</form>
  </div>   

Angular version: 1.5.7

1.5.7

Browser: [all | Chrome XX | Firefox XX | IE XX | Safari XX | Mobile Chrome XX | Android X.X Web Browser | iOS XX Safari | iOS XX UIWebView | iOS XX WKWebView ]

Chrome 56.0.2924.87, Windows

Anything else:

Maybe check some regexp

@gkalpak
Copy link
Member

gkalpak commented Mar 28, 2017

According to RFC 5321 - 2.3.5:

A domain name (or often just a "domain") consists of one or more components, separated by dots if more than one appears.
[...]
These components ("labels" in DNS terminology, RFC 1035) are restricted for SMTP purposes to consist of a sequence of letters, digits, and hyphens drawn from the ASCII character set.

This means that the part appearing after the @ is not allowed to contain non-ASCII characters (such as в). Normally, any length of в should make the URL invalid. But what Chrome (maybe other browsers too - I only tried on Chrome) change the value of the input to [email protected] (i.e. substitute в with a and prepend xn--b1 to every sequences of вs. So ввв will become xn--b1aaa for example).

Which is not what you want of cource (but AngularJS can't do anything about it - it's the browser). As a result, the URL is valid (because it contains ASCII characters.

Furthrmore, according to RFC 1035 - 2.3.4, each "label" (domain name component) should be "labels 63 octets or less". This means that you can have only 63 characters per "label" (i.e. domain components). Since Chrome will add an extra 6 characters (xn--b1) at the beginning of the label, you can only have 57 (63 - 6) вs. (The same way you culd only have 63 Bs.)

Closing, since this works as expected as far as AngularJS is concerned (not sure about the Chrome behavior).

BTW, you can find some discussions (and useful references) about email validation in #14719.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants