Documentation ¶
Overview ¶
Package user provides tools for parsing and validating user names.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clean ¶
Clean returns the user name in canonical form as described by the comments for the Parse function.
func Parse ¶
Parse splits an upspin.UserName into user and domain and returns the pair. It also returns the "+" suffix part of the user name, if it has one. For example, given the user name
ann+backup@example.com
it would return the strings
"ann+backup" "backup" "example.com"
Parsed validates the name as an e-mail address and lower-cases the domain so it is canonical.
The rules are:
<name> := <user name>@<domain name> <domain name> := - each . separated token < 64 characters - character set for tokens [a-z0-9\-] - final token at least two characters - whole name < 254 characters - characters are case insensitive - final period is OK, but we remove it
We ignore the rules of punycode, which is defined in https://tools.ietf.org/html/rfc3490 .
<user name> :=
Names are validated and canonicalized by the UsernameCasePreserved profile of the RFC 7613, "Preparation, Enforcement, and Comparison of Internationalized Strings", also known as PRECIS.
Further restrictions are added here. The only ASCII punctuation characters that are legal are "!#$%&'*+-/=?^_{|}~", and a name that is only ASCII punctuation is rejected.
As a special case for use in Access and Group files, the name "*" is allowed.
Case is significant and spaces are not allowed.
The username suffix is tightly constrained: It uses the same character set as domains, but of course the spacing of periods is irrelevant.
Facebook and Google constrain usernames to [a-zA-Z0-9+-.], ignoring the period and, in Google only, ignoring everything from a plus sign onwards. We accept a superset of this but do not follow the "ignore" rules.
func ParseDomain ¶
ParseDomain parses the component of a user name after the '@', that is, the domain component of an email address. The rules are defined in the documentation for Parse except the domain name itself must be less than 255 bytes long.
Types ¶
This section is empty.