libidn  1.38
profiles.c
Go to the documentation of this file.
1 /* profiles.c --- Definitions of stringprep profiles.
2  Copyright (C) 2002-2021 Simon Josefsson
3 
4  This file is part of GNU Libidn.
5 
6  GNU Libidn is free software: you can redistribute it and/or
7  modify it under the terms of either:
8 
9  * the GNU Lesser General Public License as published by the Free
10  Software Foundation; either version 3 of the License, or (at
11  your option) any later version.
12 
13  or
14 
15  * the GNU General Public License as published by the Free
16  Software Foundation; either version 2 of the License, or (at
17  your option) any later version.
18 
19  or both in parallel, as here.
20 
21  GNU Libidn is distributed in the hope that it will be useful,
22  but WITHOUT ANY WARRANTY; without even the implied warranty of
23  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
24  General Public License for more details.
25 
26  You should have received copies of the GNU General Public License and
27  the GNU Lesser General Public License along with this program. If
28  not, see <http://www.gnu.org/licenses/>. */
29 
30 #include <config.h>
31 #include "stringprep.h"
32 #include "rfc3454.h"
33 
35  {"Nameprep", stringprep_nameprep},
36  {"KRBprep", stringprep_kerberos5}, /* Deprecate? */
37  {"Nodeprep", stringprep_xmpp_nodeprep},
38  {"Resourceprep", stringprep_xmpp_resourceprep},
39  {"plain", stringprep_plain}, /* sasl-anon-00. */
40  {"trace", stringprep_trace}, /* sasl-anon-01,02,03. */
41  {"SASLprep", stringprep_saslprep},
42  {"ISCSIprep", stringprep_iscsi}, /* Obsolete. */
43  {"iSCSI", stringprep_iscsi}, /* IANA. */
44  {NULL, NULL}
45 };
46 
47 /* number of elements within an array */
48 #define countof(a) (sizeof(a)/sizeof(*(a)))
49 
50 /* helper for profile definitions */
51 #define TABLE(x) stringprep_rfc3454_##x, N_STRINGPREP_rfc3454_##x
52 
54  {STRINGPREP_MAP_TABLE, 0, TABLE (B_1)},
55  {STRINGPREP_MAP_TABLE, 0, TABLE (B_2)},
56  {STRINGPREP_NFKC, 0, 0, 0},
57  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_1_2)},
58  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_2)},
59  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_3)},
60  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_4)},
61  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_5)},
62  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_6)},
63  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_7)},
64  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_8)},
65  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_9)},
66  {STRINGPREP_BIDI, 0, 0, 0},
68  {STRINGPREP_BIDI_RAL_TABLE, 0, TABLE (D_1)},
69  {STRINGPREP_BIDI_L_TABLE, 0, TABLE (D_2)},
71  {0}
72 };
73 
75  /* XXX this is likely to be wrong as the specification is
76  a rough draft. */
77  {STRINGPREP_MAP_TABLE, 0, TABLE (B_1)},
78  {STRINGPREP_MAP_TABLE, 0, TABLE (B_3)},
79  {STRINGPREP_NFKC, 0, 0, 0},
80  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_1_2)},
81  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_2)},
82  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_3)},
83  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_4)},
84  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_5)},
85  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_6)},
86  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_7)},
87  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_8)},
88  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_9)},
89  {STRINGPREP_BIDI, 0, 0, 0},
91  {STRINGPREP_BIDI_RAL_TABLE, 0, TABLE (D_1)},
92  {STRINGPREP_BIDI_L_TABLE, 0, TABLE (D_2)},
94  {0}
95 };
96 
98  {0x000022, 0x000022}, /* #x22 (") */
99  {0x000026, 0x000026}, /* #x26 (&) */
100  {0x000027, 0x000027}, /* #x27 (') */
101  {0x00002F, 0x00002F}, /* #x2F (/) */
102  {0x00003A, 0x00003A}, /* #x3A (:) */
103  {0x00003C, 0x00003C}, /* #x3C (<) */
104  {0x00003E, 0x00003E}, /* #x3E (>) */
105  {0x000040, 0x000040}, /* #x40 (@) */
106  {0}
107 };
108 
110  {STRINGPREP_MAP_TABLE, 0, TABLE (B_1)},
111  {STRINGPREP_MAP_TABLE, 0, TABLE (B_2)},
112  {STRINGPREP_NFKC, 0, 0, 0},
113  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_1_1)},
114  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_1_2)},
115  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_1)},
116  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_2)},
117  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_3)},
118  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_4)},
119  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_5)},
120  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_6)},
121  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_7)},
122  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_8)},
123  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_9)},
126  {STRINGPREP_BIDI, 0, 0, 0},
128  {STRINGPREP_BIDI_RAL_TABLE, 0, TABLE (D_1)},
129  {STRINGPREP_BIDI_L_TABLE, 0, TABLE (D_2)},
131  {0}
132 };
133 
135  {STRINGPREP_MAP_TABLE, 0, TABLE (B_1)},
136  {STRINGPREP_NFKC, 0, 0, 0},
137  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_1_2)},
138  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_1)},
139  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_2)},
140  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_3)},
141  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_4)},
142  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_5)},
143  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_6)},
144  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_7)},
145  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_8)},
146  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_9)},
147  {STRINGPREP_BIDI, 0, 0, 0},
152  {0}
153 };
154 
156  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_1)},
157  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_2)},
158  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_3)},
159  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_4)},
160  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_5)},
161  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_6)},
162  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_8)},
163  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_9)},
164  {STRINGPREP_BIDI, 0, 0, 0},
168  {0}
169 };
170 
172  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_1)},
173  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_2)},
174  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_3)},
175  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_4)},
176  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_5)},
177  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_6)},
178  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_8)},
179  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_9)},
180  {STRINGPREP_BIDI, 0, 0, 0},
184  {0}
185 };
186 
188  {0x0000, 0x002C}, /* [ASCII CONTROL CHARACTERS and SPACE through ,] */
189  {0x002F, 0x002F}, /* [ASCII /] */
190  {0x003B, 0x0040}, /* [ASCII ; through @] */
191  {0x005B, 0x0060}, /* [ASCII [ through `] */
192  {0x007B, 0x007F}, /* [ASCII { through DEL] */
193  {0x3002, 0x3002}, /* ideographic full stop */
194  {0}
195 };
196 
198  {STRINGPREP_MAP_TABLE, 0, TABLE (B_1)},
199  {STRINGPREP_MAP_TABLE, 0, TABLE (B_2)},
200  {STRINGPREP_NFKC, 0, 0, 0},
201  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_1_1)},
202  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_1_2)},
203  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_1)},
204  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_2)},
205  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_3)},
206  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_4)},
207  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_5)},
208  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_6)},
209  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_7)},
210  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_8)},
211  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_9)},
214  {STRINGPREP_BIDI, 0, 0, 0},
219  {0}
220 };
221 
223  {0x00A0, 0x00A0, {0x0020}}, /* 00A0; NO-BREAK SPACE */
224  {0x1680, 0x1680, {0x0020}}, /* 1680; OGHAM SPACE MARK */
225  {0x2000, 0x200B, {0x0020}}, /* 2000; EN QUAD */
226  /* 2001; EM QUAD */
227  /* 2002; EN SPACE */
228  /* 2003; EM SPACE */
229  /* 2004; THREE-PER-EM SPACE */
230  /* 2005; FOUR-PER-EM SPACE */
231  /* 2006; SIX-PER-EM SPACE */
232  /* 2007; FIGURE SPACE */
233  /* 2008; PUNCTUATION SPACE */
234  /* 2009; THIN SPACE */
235  /* 200A; HAIR SPACE */
236  /* 200B; ZERO WIDTH SPACE */
237  {0x202F, 0x202F, {0x0020}}, /* 202F; NARROW NO-BREAK SPACE */
238  {0x205F, 0x205F, {0x0020}}, /* 205F; MEDIUM MATHEMATICAL SPACE */
239  {0x3000, 0x3000, {0x0020}}, /* 3000; IDEOGRAPHIC SPACE */
240  {0}
241 };
242 
246  {STRINGPREP_MAP_TABLE, 0, TABLE (B_1)},
247  {STRINGPREP_NFKC, 0, 0, 0},
248  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_1_2)},
249  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_1)},
250  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_2_2)},
251  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_3)},
252  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_4)},
253  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_5)},
254  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_6)},
255  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_7)},
256  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_8)},
257  {STRINGPREP_PROHIBIT_TABLE, 0, TABLE (C_9)},
258  {STRINGPREP_BIDI, 0, 0, 0},
263  {0}
264 };
const Stringprep_profile stringprep_kerberos5[]
Definition: profiles.c:74
const Stringprep_profile stringprep_plain[]
Definition: profiles.c:155
#define countof(a)
Definition: profiles.c:48
const Stringprep_table_element stringprep_xmpp_nodeprep_prohibit[]
Definition: profiles.c:97
const Stringprep_profile stringprep_saslprep[]
Definition: profiles.c:243
const Stringprep_profile stringprep_iscsi[]
Definition: profiles.c:197
const Stringprep_profiles stringprep_profiles[]
Definition: profiles.c:34
const Stringprep_profile stringprep_xmpp_nodeprep[]
Definition: profiles.c:109
const Stringprep_profile stringprep_trace[]
Definition: profiles.c:171
const Stringprep_profile stringprep_nameprep[]
Definition: profiles.c:53
#define TABLE(x)
Definition: profiles.c:51
const Stringprep_profile stringprep_xmpp_resourceprep[]
Definition: profiles.c:134
const Stringprep_table_element stringprep_iscsi_prohibit[]
Definition: profiles.c:187
const Stringprep_table_element stringprep_saslprep_space_map[]
Definition: profiles.c:222
@ STRINGPREP_BIDI_PROHIBIT_TABLE
Definition: stringprep.h:101
@ STRINGPREP_BIDI_RAL_TABLE
Definition: stringprep.h:102
@ STRINGPREP_NFKC
Definition: stringprep.h:96
@ STRINGPREP_PROHIBIT_TABLE
Definition: stringprep.h:100
@ STRINGPREP_UNASSIGNED_TABLE
Definition: stringprep.h:99
@ STRINGPREP_BIDI
Definition: stringprep.h:97
@ STRINGPREP_MAP_TABLE
Definition: stringprep.h:98
@ STRINGPREP_BIDI_L_TABLE
Definition: stringprep.h:103
@ STRINGPREP_NO_BIDI
Definition: stringprep.h:89
@ STRINGPREP_NO_UNASSIGNED
Definition: stringprep.h:90