Module: Net::IMAP::StringPrep::NamePrep

Defined in:
lib/net/imap/stringprep/nameprep.rb

Overview

Defined in RFC3491, the nameprep profile of “Stringprep” is:

used by the IDNA protocol for preparing domain names; it is not designed for any other purpose. It is explicitly not designed for processing arbitrary free text and SHOULD NOT be used for that purpose.

This profile specifies prohibiting using the following tables…:

  • C.1.2 (Non-ASCII space characters)

  • C.2.2 (Non-ASCII control characters)

  • C.3 (Private use characters)

  • C.4 (Non-character code points)

  • C.5 (Surrogate codes)

  • C.6 (Inappropriate for plain text)

  • C.7 (Inappropriate for canonical representation)

  • C.8 (Change display properties are deprecated)

  • C.9 (Tagging characters)

IMPORTANT NOTE: This profile MUST be used with the IDNA protocol. The IDNA protocol has additional prohibitions that are checked outside of this profile.

Constant Summary collapse

STRINGPREP_PROFILE =

From RFC3491 §10

"nameprep"
UNASSIGNED_TABLE =

From RFC3491 §2

"A.1"
MAPPING_TABLES =

From RFC3491 §3

%w[B.1 B.2].freeze
NORMALIZATION =

From RFC3491 §4

:nfkc
PROHIBITED_TABLES =

From RFC3491 §5

%w[C.1.2 C.2.2 C.3 C.4 C.5 C.6 C.7 C.8 C.9].freeze
CHECK_BIDI =

From RFC3491 §6

true

Class Method Summary collapse

Class Method Details

.nameprep(string, **opts) ⇒ Object



54
55
56
57
58
59
60
61
62
63
64
65
# File 'lib/net/imap/stringprep/nameprep.rb', line 54

def nameprep(string, **opts)
  StringPrep.stringprep(
    string,
    unassigned:    UNASSIGNED_TABLE,
    maps:          MAPPING_TABLES,
    prohibited:    PROHIBITED_TABLES,
    normalization: NORMALIZATION,
    bidi:          CHECK_BIDI,
    profile:       STRINGPREP_PROFILE,
    **opts,
  )
end