@@ -24,11 +24,6 @@ class DomainName extends Type
2424{
2525 const FLAG_NO_COMPRESSION = 0x80000000 ;
2626
27- /**
28- * @var callable|null
29- */
30- private static $ labelPreProcessor = null ;
31-
3227 /**
3328 * @var string
3429 */
@@ -47,27 +42,6 @@ class DomainName extends Type
4742 */
4843 public function __construct ($ value = null )
4944 {
50- if (!isset (self ::$ labelPreProcessor )) {
51- self ::$ labelPreProcessor = \function_exists ('idn_to_ascii ' )
52- ? static function ($ label ) {
53- if (false === $ result = \idn_to_ascii ($ label , 0 , INTL_IDNA_VARIANT_UTS46 )) {
54- throw new \InvalidArgumentException ("Label ' {$ label }' could not be processed for IDN " );
55- }
56-
57- return $ result ;
58- }
59- : static function ($ label ) {
60- if (\preg_match ('/[\x80-\xff]/ ' , $ label )) {
61- throw new \RuntimeException (
62- "Label ' {$ label }' contains non-ASCII characters and IDN support is not available. "
63- . " Verify that ext/intl is installed for IDN support. "
64- );
65- }
66-
67- return \strtolower ($ label );
68- };
69- }
70-
7145 if (\is_array ($ value )) {
7246 $ this ->setLabels ($ value );
7347 } else {
@@ -113,7 +87,7 @@ public function setLabels(array $labels, $tldFirst = false)
11387 $ length = $ count = 0 ;
11488
11589 foreach ($ labels as &$ label ) {
116- $ label = ( self :: $ labelPreProcessor ) ($ label );
90+ $ label = \ LibDNS \normalize_name ($ label );
11791 $ labelLength = \strlen ($ label );
11892 if ($ labelLength > 63 ) {
11993 throw new \InvalidArgumentException ('Label list is not a valid domain name: Label ' . $ label . ' length exceeds 63 byte limit ' );
0 commit comments