Mstdlib-1.24.0
Verification

Validation of strings against various standards (email address, domain name, etc.). More...

Enumerations

enum  M_verify_email_listdelim_t {
  M_VERIFY_EMAIL_LISTDELIM_AUTO = 0 ,
  M_VERIFY_EMAIL_LISTDELIM_SEMICOLON ,
  M_VERIFY_EMAIL_LISTDELIM_COMMA
}
 

Functions

M_bool M_verify_email_address (const char *addr)
 
M_bool M_verify_domain (const char *dname)
 
M_bool M_verify_email_address_list (const char *addr_list, M_verify_email_listdelim_t delim_type)
 

Detailed Description

Validation of strings against various standards (email address, domain name, etc.).

Enumeration Type Documentation

◆ M_verify_email_listdelim_t

Enumerator
M_VERIFY_EMAIL_LISTDELIM_AUTO 
M_VERIFY_EMAIL_LISTDELIM_SEMICOLON 
M_VERIFY_EMAIL_LISTDELIM_COMMA 

Function Documentation

◆ M_verify_email_address()

M_bool M_verify_email_address ( const char *  addr)

Verify that the given single email address is valid.

An email address is composed of the following parts:

display_name<local_part@domain>

The display name may contain double-quotes. Within double-quotes, the full range of symbols may be used (dot, comma, semicolon, at, escaped double-quote, etc.). The space and tab characters are allowed in the display name, even outside of quotes.

If the display name is not provided, the angle brackets around the rest of the email address are optional.

This email address validator differs from the RFC standards for email in the following ways:

  • Double quotes are not allowed, except in the display name (a.k.a. friendly name).
  • Comments (chunks of text enclosed by parentheses) are not allowed, though parenthesis are allowed in the display name if they're surrounded by double-quotes.
  • Consecutive dots are allowed in the local part of the address, since they are accepted by gmail.
  • Only the following non-alphanumeric characters are allowed in the local part:
    '*+-=^_{}.~ 
  • IP address domains are not allowed (e.g., joe.smith@[192.168.2.1] is invalid).
  • UTF-8 is not allowed in any part of the address (display name, local part, or domain name).

Example of valid address:

"Public, John Q. (Support)" <jq..public+support@generic-server.com> 
See also
M_verify_email_address_list
Parameters
[in]addremail address to verify
Returns
TRUE if the address is valid

◆ M_verify_domain()

M_bool M_verify_domain ( const char *  dname)

Verify that the given domain name is valid.

Valid domain names are composed of letters, digits, and hyphens ('-'), separated into sections by dots ('.'). Each section is limited to 63 chars, and may not begin or end with a hyphen. The entire domain name is limited to 253 characters - note that a 253 character domain name takes 255 bytes to store with the length-prefixed encoding used by DNS.

Parameters
[in]dnamedomain name to verify
Returns
TRUE if the domain name is valid

◆ M_verify_email_address_list()

M_bool M_verify_email_address_list ( const char *  addr_list,
M_verify_email_listdelim_t  delim_type 
)

Verify that the given list of email addresses is valid.

The list may be delimited by either commas (',') or semicolons (';'), but not both. This function limits the number of addresses in the list to 100 - this isn't a true standard, but it's the limit used virutally everywhere in practice.

The list parser is tolerant of whitespace - individual addresses are trimmed before they're passed to the email address validator.

The individual addresses in the list may include display names (a.k.a friendly names).

See also
M_verify_email_address
Parameters
[in]addr_listlist of email addresses to verify
[in]delim_typeType of delimiter to expect. Can be auto detected.
Returns
TRUE if the list and all emails in it are valid