@@ -284,6 +284,55 @@ public function testEncodePhp53($decoded, $encoded)
284
284
$ this ->assertSame ($ encoded , $ result );
285
285
}
286
286
287
+ /**
288
+ * IDNA 15.1.0 revision 31
289
+ *
290
+ * This tests the change in "Section 4 Processing step 1. Map" which conditionally maps U+1E9E capital sharp s to
291
+ * "ss" if Transitional_Processing is used.
292
+ *
293
+ * @dataProvider captialSharpSProvider
294
+ */
295
+ public function testCapitalSharpSProcessing ($ input , $ expected , $ flags )
296
+ {
297
+ idn_to_utf8 ($ input , $ flags , \INTL_IDNA_VARIANT_UTS46 , $ info );
298
+ $ this ->assertSame ($ expected , $ info ['result ' ]);
299
+ }
300
+
301
+ /**
302
+ * IDNA 15.1.0 revision 31
303
+ *
304
+ * This tests the additional validity check in "Section 4.1 Validity Criteria Processing step 4", which is used to
305
+ * disallow labels that do not round trip.
306
+ */
307
+ public function testLabelsThatDoNotRoundTripAreDisallowed ()
308
+ {
309
+ idn_to_utf8 ('xn--xn---epa. ' , \IDNA_DEFAULT , \INTL_IDNA_VARIANT_UTS46 , $ info1 );
310
+ idn_to_ascii ($ info1 ['result ' ], \IDNA_DEFAULT , \INTL_IDNA_VARIANT_UTS46 , $ info2 );
311
+ $ this ->assertSame (\IDNA_ERROR_PUNYCODE , \IDNA_ERROR_PUNYCODE & $ info2 ['errors ' ]);
312
+ }
313
+
314
+ /**
315
+ * IDNA 15.1.0 revision 31
316
+ *
317
+ * This tests the the additional condition in "Section 4 Processing step 4.1" where a label that starts with "xn--"
318
+ * and contains a non-ASCII codepoint records an error and the processing steps continue with the next label.
319
+ */
320
+ public function testLabelStartingWithPunycodePrefixWithNonAsciiCharacterRecordsErrorAndIsSkipped ()
321
+ {
322
+ \idn_to_utf8 ('xn--🌈.xn--fa-hia.de ' , \IDNA_DEFAULT , \INTL_IDNA_VARIANT_UTS46 , $ info );
323
+ $ this ->assertSame (\IDNA_ERROR_PUNYCODE , \IDNA_ERROR_PUNYCODE & $ info ['errors ' ]);
324
+ $ this ->assertSame ('xn--🌈.faß.de ' , $ info ['result ' ]);
325
+ }
326
+
327
+ public static function captialSharpSProvider ()
328
+ {
329
+ return [
330
+ ['Faß.de ' , 'fass.de ' , \IDNA_DEFAULT ],
331
+ ['Faß.de ' , 'faß.de ' , \IDNA_NONTRANSITIONAL_TO_UNICODE ],
332
+ ];
333
+ }
334
+
335
+
287
336
public static function domainNamesProvider ()
288
337
{
289
338
return [
0 commit comments