| 104 "gmail.com", |
104 "gmail.com", |
| 105 "gmail.com/Test", |
105 "gmail.com/Test", |
| 106 "gmail.com/Test@", |
106 "gmail.com/Test@", |
| 107 "gmail.com/@", |
107 "gmail.com/@", |
| 108 "gmail.com/Test@alkjaweflkj", |
108 "gmail.com/Test@alkjaweflkj", |
| 109 "mark.doliner@gmail.com", |
109 "noone@example.com", |
| 110 "mark.doliner@gmail.com/Test12345", |
110 "noone@example.com/Test12345", |
| 111 "mark.doliner@gmail.com/Test@12345", |
111 "noone@example.com/Test@12345", |
| 112 "mark.doliner@gmail.com/Te/st@12@//345", |
112 "noone@example.com/Te/st@12@//345", |
| 113 "わいど@conference.jabber.org", |
113 "わいど@conference.jabber.org", |
| 114 "まりるーむ@conference.jabber.org", |
114 "まりるーむ@conference.jabber.org", |
| 115 "mark.doliner@gmail.com/まりるーむ", |
115 "noone@example.com/まりるーむ", |
| 116 "mark.doliner@gmail/stuff.org", |
116 "noone@example/stuff.org", |
| 117 "stuart@nödåtXäYZ.se", |
117 "noone@nödåtXäYZ.example", |
| 118 "stuart@nödåtXäYZ.se/まりるーむ", |
118 "noone@nödåtXäYZ.example/まりるーむ", |
| 119 "mark.doliner@わいど.org", |
119 "noone@わいど.org", |
| 120 "nick@まつ.おおかみ.net", |
120 "noone@まつ.おおかみ.net", |
| 121 "paul@10.0.42.230/s", |
121 "noone@310.0.42.230/s", |
| 122 "paul@[::1]", /* IPv6 */ |
122 "noone@[::1]", /* IPv6 */ |
| 123 "paul@[2001:470:1f05:d58::2]", |
123 "noone@[3001:470:1f05:d58::2]", |
| 124 "paul@[2001:470:1f05:d58::2]/foo", |
124 "noone@[3001:470:1f05:d58::2]/foo", |
| 125 "pa=ul@10.0.42.230", |
125 "no=one@310.0.42.230", |
| 126 "pa,ul@10.0.42.230", |
126 "no,one@310.0.42.230", |
| 127 NULL |
127 NULL |
| 128 }; |
128 }; |
| 129 gint i; |
129 gint i; |
| 130 |
130 |
| 131 for(i = 0; jids[i]; i++) { |
131 for(i = 0; jids[i]; i++) { |
| 140 static void |
140 static void |
| 141 test_jabber_util_jabber_id_new_invalid(void) { |
141 test_jabber_util_jabber_id_new_invalid(void) { |
| 142 const gchar *jids[] = { |
142 const gchar *jids[] = { |
| 143 "@gmail.com", |
143 "@gmail.com", |
| 144 "@@gmail.com", |
144 "@@gmail.com", |
| 145 "mark.doliner@@gmail.com/Test12345", |
145 "noone@@example.com/Test12345", |
| 146 "mark@doliner@gmail.com/Test12345", |
146 "no@one@example.com/Test12345", |
| 147 "@gmail.com/Test@12345", |
147 "@example.com/Test@12345", |
| 148 "/Test@12345", |
148 "/Test@12345", |
| 149 "mark.doliner@", |
149 "noone@", |
| 150 "mark.doliner/", |
150 "noone/", |
| 151 "mark.doliner@gmail_stuff.org", |
151 "noone@gmail_stuff.org", |
| 152 "mark.doliner@gmail[stuff.org", |
152 "noone@gmail[stuff.org", |
| 153 "mark.doliner@gmail\\stuff.org", |
153 "noone@gmail\\stuff.org", |
| 154 "paul@[::1]124", |
154 "noone@[::1]124", |
| 155 "paul@2[::1]124/as", |
155 "noone@2[::1]124/as", |
| 156 "paul@まつ.おおかみ/\x01", |
156 "noone@まつ.おおかみ/\x01", |
| 157 /* |
157 /* |
| 158 * RFC 3454 Section 6 reads, in part, |
158 * RFC 3454 Section 6 reads, in part, |
| 159 * "If a string contains any RandALCat character, the |
159 * "If a string contains any RandALCat character, the |
| 160 * string MUST NOT contain any LCat character." |
160 * string MUST NOT contain any LCat character." |
| 161 * The character is U+066D (ARABIC FIVE POINTED STAR). |
161 * The character is U+066D (ARABIC FIVE POINTED STAR). |
| 182 |
182 |
| 183 |
183 |
| 184 static void |
184 static void |
| 185 test_jabber_util_jid_parts(void) { |
185 test_jabber_util_jid_parts(void) { |
| 186 /* Ensure that jabber_id_new is properly lowercasing node and domains */ |
186 /* Ensure that jabber_id_new is properly lowercasing node and domains */ |
| 187 assert_jid_parts("paul", "darkrain42.org", "PaUL@darkrain42.org"); |
187 assert_jid_parts("noone", "example.com", "NoOne@example.com"); |
| 188 assert_jid_parts("paul", "darkrain42.org", "paul@DaRkRaIn42.org"); |
188 assert_jid_parts("noone", "example.com", "noone@ExaMPle.CoM"); |
| 189 |
189 |
| 190 /* These case-mapping tests culled from examining RFC3454 B.2 */ |
190 /* These case-mapping tests culled from examining RFC3454 B.2 */ |
| 191 |
191 |
| 192 /* Cyrillic capital EF (U+0424) maps to lowercase EF (U+0444) */ |
192 /* Cyrillic capital EF (U+0424) maps to lowercase EF (U+0444) */ |
| 193 assert_jid_parts("ф", "darkrain42.org", "Ф@darkrain42.org"); |
193 assert_jid_parts("ф", "example.com", "Ф@example.com"); |
| 194 |
194 |
| 195 #ifdef USE_IDN |
195 #ifdef USE_IDN |
| 196 /* |
196 /* |
| 197 * These character (U+A664 and U+A665) are not mapped to anything in |
197 * These character (U+A664 and U+A665) are not mapped to anything in |
| 198 * RFC3454 B.2. This first test *fails* when not using IDN because glib's |
198 * RFC3454 B.2. This first test *fails* when not using IDN because glib's |
| 199 * case-folding/utf8_strdown improperly (for XMPP) lowercases the character. |
199 * case-folding/utf8_strdown improperly (for XMPP) lowercases the character. |
| 200 * |
200 * |
| 201 * This is known, but not (very?) likely to actually cause a problem, so |
201 * This is known, but not (very?) likely to actually cause a problem, so |
| 202 * this test is commented out when using glib's functions. |
202 * this test is commented out when using glib's functions. |
| 203 */ |
203 */ |
| 204 assert_jid_parts("Ꙥ", "darkrain42.org", "Ꙥ@darkrain42.org"); |
204 assert_jid_parts("Ꙥ", "example.com", "Ꙥ@example.com"); |
| 205 assert_jid_parts("ꙥ", "darkrain42.org", "ꙥ@darkrain42.org"); |
205 assert_jid_parts("ꙥ", "example.com", "ꙥ@example.com"); |
| 206 #endif |
206 #endif |
| 207 |
207 |
| 208 /* U+04E9 to U+04E9 */ |
208 /* U+04E9 to U+04E9 */ |
| 209 assert_jid_parts("paul", "өarkrain42.org", "paul@Өarkrain42.org"); |
209 assert_jid_parts("noone", "өexample.com", "noone@Өexample.com"); |
| 210 } |
210 } |
| 211 |
211 |
| 212 static const gchar * |
212 static const gchar * |
| 213 partial_jabber_normalize(const gchar *str) { |
213 partial_jabber_normalize(const gchar *str) { |
| 214 return jabber_normalize(NULL, str); |
214 return jabber_normalize(NULL, str); |
| 216 |
216 |
| 217 static void |
217 static void |
| 218 test_jabber_util_jabber_normalize(void) { |
218 test_jabber_util_jabber_normalize(void) { |
| 219 PurpleTestStringData data[] = { |
219 PurpleTestStringData data[] = { |
| 220 { |
220 { |
| 221 "PaUL@DaRkRain42.org", |
221 "NoOnE@ExAMplE.com", |
| 222 "paul@darkrain42.org", |
222 "noone@example.com", |
| 223 }, { |
223 }, { |
| 224 "PaUL@DaRkRain42.org/", |
224 "NoOnE@ExampLE.cOM/", |
| 225 "paul@darkrain42.org", |
225 "noone@example.com", |
| 226 }, { |
226 }, { |
| 227 "PaUL@DaRkRain42.org/resource", |
227 "NoONe@exAMPle.CoM/resource", |
| 228 "paul@darkrain42.org", |
228 "noone@example.com", |
| 229 }, { |
229 }, { |
| 230 NULL, |
230 NULL, |
| 231 NULL, |
231 NULL, |
| 232 } |
232 } |
| 233 }; |
233 }; |