@@ -9,22 +9,25 @@ module Net::IMAP::StringPrep
9
9
module SASLprep
10
10
11
11
# RFC4013 §2.1 Mapping - mapped to space
12
- # * non-ASCII space characters (\StringPrep\[\"C.1.2\"]) that can be
13
- # mapped to SPACE (U+0020), and
12
+ # >>>
13
+ # non-ASCII space characters (\StringPrep\[\"C.1.2\"]) that can
14
+ # be mapped to SPACE (U+0020)
14
15
#
15
16
# Equal to \StringPrep\[\"C.1.2\"].
16
- # Redefined here to avoid loading the StringPrep module .
17
+ # Redefined here to avoid loading StringPrep::Tables unless necessary .
17
18
MAP_TO_SPACE = /[\u200b \p {Zs}&&[^ ]]/ . freeze
18
19
19
20
# RFC4013 §2.1 Mapping - mapped to nothing
20
- # the "commonly mapped to nothing" characters (\StringPrep\[\"B.1\"])
21
- # that can be mapped to nothing.
21
+ # >>>
22
+ # the "commonly mapped to nothing" characters
23
+ # (\StringPrep\[\"B.1\"]) that can be mapped to nothing.
22
24
#
23
25
# Equal to \StringPrep\[\"B.1\"].
24
- # Redefined here to avoid loading the StringPrep module .
26
+ # Redefined here to avoid loading StringPrep::Tables unless necessary .
25
27
MAP_TO_NOTHING = /[\u{00ad 034f 1806 2060 feff} \u{180b} -\u{180d} \u{200b} -\u{200d} \u{fe00} -\u{fe0f} ]/ . freeze
26
28
27
- # RFC4013 §2.3 Prohibited Output::
29
+ # RFC4013 §2.3 Prohibited Output
30
+ # >>>
28
31
# * Non-ASCII space characters — \StringPrep\[\"C.1.2\"]
29
32
# * ASCII control characters — \StringPrep\[\"C.2.1\"]
30
33
# * Non-ASCII control characters — \StringPrep\[\"C.2.2\"]
@@ -39,32 +42,40 @@ module SASLprep
39
42
40
43
# Adds unassigned (by Unicode 3.2) codepoints to TABLES_PROHIBITED.
41
44
#
42
- # RFC4013 §2.5 Unassigned Code Points::
43
- # This profile specifies the \StringPrep\[\"A.1\"] table as its list of
44
- # unassigned code points.
45
+ # RFC4013 §2.5 Unassigned Code Points
46
+ # >>>
47
+ # This profile specifies the \StringPrep\[\"A.1\"] table as its
48
+ # list of unassigned code points.
45
49
TABLES_PROHIBITED_STORED = [ "A.1" , *TABLES_PROHIBITED ] . freeze
46
50
47
- # Matches codepoints prohibited by RFC4013 §2.3.
51
+ # A Regexp matching codepoints prohibited by RFC4013 §2.3.
48
52
#
49
- # See TABLES_PROHIBITED.
50
- #
51
- # Equal to +Regexp.union+ of the TABLES_PROHIBITED tables. Redefined
52
- # here to avoid loading the StringPrep module unless necessary.
53
+ # This combines all of the TABLES_PROHIBITED tables.
53
54
PROHIBITED_OUTPUT = /[\u{06dd 070f 1680 180e 3000 feff e0001} \u{0000} -\u{001f} \u{007f} -\u{00a0} \u{0340} -\u{0341} \u{2000} -\u{200f} \u{2028} -\u{202f} \u{205f} -\u{2063} \u{206a} -\u{206f} \u{2ff0} -\u{2ffb} \u{e000} -\u{f8ff} \u{fdd0} -\u{fdef} \u{fff9} -\u{ffff} \u{1d173} -\u{1d17a} \u{1fffe} -\u{1ffff} \u{2fffe} -\u{2ffff} \u{3fffe} -\u{3ffff} \u{4fffe} -\u{4ffff} \u{5fffe} -\u{5ffff} \u{6fffe} -\u{6ffff} \u{7fffe} -\u{7ffff} \u{8fffe} -\u{8ffff} \u{9fffe} -\u{9ffff} \u{afffe} -\u{affff} \u{bfffe} -\u{bffff} \u{cfffe} -\u{cffff} \u{dfffe} -\u{dffff} \u{e0020} -\u{e007f} \u{efffe} -\u{10ffff} \p {Cs}]/ . freeze
54
55
55
- # RFC4013 §2.5 Unassigned Code Points::
56
- # This profile specifies the \StringPrep\[\"A.1\"] table as its list of
57
- # unassigned code points.
56
+ # RFC4013 §2.5 Unassigned Code Points
57
+ # >>>
58
+ # This profile specifies the \StringPrep\[\"A.1\"] table as its
59
+ # list of unassigned code points.
60
+ #
61
+ # Equal to \StringPrep\[\"A.1\"].
62
+ # Redefined here to avoid loading StringPrep::Tables unless necessary.
58
63
UNASSIGNED = /\p {^AGE=3.2}/ . freeze
59
64
60
- # Matches codepoints prohibited by RFC4013 §2.3 and §2.5.
65
+ # A Regexp matching codepoints prohibited by RFC4013 §2.3 and §2.5.
61
66
#
62
- # See TABLES_PROHIBITED_STORED .
67
+ # This combines PROHIBITED_OUTPUT and UNASSIGNED .
63
68
PROHIBITED_OUTPUT_STORED = Regexp . union (
64
69
UNASSIGNED , PROHIBITED_OUTPUT
65
70
) . freeze
66
71
67
72
# Bidirectional Characters [StringPrep, §6]
73
+ #
74
+ # A Regexp for strings that don't satisfy StringPrep's Bidirectional
75
+ # Characters rules.
76
+ #
77
+ # Equal to StringPrep::Tables::BIDI_FAILURE.
78
+ # Redefined here to avoid loading StringPrep::Tables unless necessary.
68
79
BIDI_FAILURE = /(?mx-i: # RandALCat followed by LCat
69
80
(?<r_and_al_cat>[\u{05be 05c0 05c3 061b 061f 06dd 0710 07b1 200f fb1d fb3e} \u{05d0} -\u{05ea} \u{05f0} -\u{05f4} \u{0621} -\u{063a} \u{0640} -\u{064a} \u{066d} -\u{066f} \u{0671} -\u{06d5} \u{06e5} -\u{06e6} \u{06fa} -\u{06fe} \u{0700} -\u{070d} \u{0712} -\u{072c} \u{0780} -\u{07a5} \u{fb1f} -\u{fb28} \u{fb2a} -\u{fb36} \u{fb38} -\u{fb3c} \u{fb40} -\u{fb41} \u{fb43} -\u{fb44} \u{fb46} -\u{fbb1} \u{fbd3} -\u{fd3d} \u{fd50} -\u{fd8f} \u{fd92} -\u{fdc7} \u{fdf0} -\u{fdfc} \u{fe70} -\u{fe74} \u{fe76} -\u{fefc} ])
70
81
.*?
@@ -79,17 +90,16 @@ module SASLprep
79
90
\g <r_and_al_cat> .*? \g <not_r_nor_al>\z
80
91
)/mx . freeze
81
92
82
- # Matches strings prohibited by RFC4013 §2.3 and §2.4.
93
+ # A Regexp matching strings prohibited by RFC4013 §2.3 and §2.4.
83
94
#
84
- # This checks prohibited output and bidirectional characters .
95
+ # This combines PROHIBITED_OUTPUT and BIDI_FAILURE .
85
96
PROHIBITED = Regexp . union (
86
97
PROHIBITED_OUTPUT , BIDI_FAILURE ,
87
98
)
88
99
89
- # Matches strings prohibited by RFC4013 §2.3, §2.4, and §2.5.
100
+ # A Regexp matching strings prohibited by RFC4013 §2.3, §2.4, and §2.5.
90
101
#
91
- # This checks prohibited output, bidirectional characters, and
92
- # unassigned codepoints.
102
+ # This combines PROHIBITED_OUTPUT_STORED and BIDI_FAILURE.
93
103
PROHIBITED_STORED = Regexp . union (
94
104
PROHIBITED_OUTPUT_STORED , BIDI_FAILURE ,
95
105
)
0 commit comments