11
11
12
12
namespace Symfony \Polyfill \Intl \Idn ;
13
13
14
- use Exception ;
15
- use Normalizer ;
16
14
use Symfony \Polyfill \Intl \Idn \Resources \unidata \DisallowedRanges ;
17
15
use Symfony \Polyfill \Intl \Idn \Resources \unidata \Regex ;
18
16
@@ -167,7 +165,7 @@ public static function idn_to_ascii($domainName, $options = self::IDNA_DEFAULT,
167
165
if (1 === preg_match ('/[^\x00-\x7F]/ ' , $ label )) {
168
166
try {
169
167
$ label = 'xn-- ' .self ::punycodeEncode ($ label );
170
- } catch (Exception $ e ) {
168
+ } catch (\ Exception $ e ) {
171
169
$ info ->errors |= self ::ERROR_PUNYCODE ;
172
170
}
173
171
@@ -335,8 +333,8 @@ private static function process($domain, array $options, Info $info)
335
333
$ domain = self ::mapCodePoints ($ domain , $ options , $ info );
336
334
337
335
// Step 2. Normalize the domain name string to Unicode Normalization Form C.
338
- if (!Normalizer::isNormalized ($ domain , Normalizer::FORM_C )) {
339
- $ domain = Normalizer::normalize ($ domain , Normalizer::FORM_C );
336
+ if (!\ Normalizer::isNormalized ($ domain , \ Normalizer::FORM_C )) {
337
+ $ domain = \ Normalizer::normalize ($ domain , \ Normalizer::FORM_C );
340
338
}
341
339
342
340
// Step 3. Break the string into labels at U+002E (.) FULL STOP.
@@ -350,7 +348,7 @@ private static function process($domain, array $options, Info $info)
350
348
if ('xn-- ' === substr ($ label , 0 , 4 )) {
351
349
try {
352
350
$ label = self ::punycodeDecode (substr ($ label , 4 ));
353
- } catch (Exception $ e ) {
351
+ } catch (\ Exception $ e ) {
354
352
$ info ->errors |= self ::ERROR_PUNYCODE ;
355
353
356
354
continue ;
@@ -496,7 +494,7 @@ private static function validateLabel($label, Info $info, array $options, $canBe
496
494
}
497
495
498
496
// Step 1. The label must be in Unicode Normalization Form C.
499
- if (!Normalizer::isNormalized ($ label , Normalizer::FORM_C )) {
497
+ if (!\ Normalizer::isNormalized ($ label , \ Normalizer::FORM_C )) {
500
498
$ info ->errors |= self ::ERROR_INVALID_ACE_LABEL ;
501
499
}
502
500
@@ -583,7 +581,7 @@ private static function punycodeDecode($input)
583
581
584
582
for ($ j = 0 ; $ j < $ b ; ++$ j ) {
585
583
if ($ bytes [$ j ] > 0x7F ) {
586
- throw new Exception ('Invalid input ' );
584
+ throw new \ Exception ('Invalid input ' );
587
585
}
588
586
589
587
$ output [$ out ++] = $ input [$ j ];
@@ -599,17 +597,17 @@ private static function punycodeDecode($input)
599
597
600
598
for ($ k = self ::BASE ; /* no condition */ ; $ k += self ::BASE ) {
601
599
if ($ in >= $ inputLength ) {
602
- throw new Exception ('Invalid input ' );
600
+ throw new \ Exception ('Invalid input ' );
603
601
}
604
602
605
603
$ digit = self ::$ basicToDigit [$ bytes [$ in ++] & 0xFF ];
606
604
607
605
if ($ digit < 0 ) {
608
- throw new Exception ('Invalid input ' );
606
+ throw new \ Exception ('Invalid input ' );
609
607
}
610
608
611
609
if ($ digit > intdiv (self ::MAX_INT - $ i , $ w )) {
612
- throw new Exception ('Integer overflow ' );
610
+ throw new \ Exception ('Integer overflow ' );
613
611
}
614
612
615
613
$ i += $ digit * $ w ;
@@ -629,7 +627,7 @@ private static function punycodeDecode($input)
629
627
$ baseMinusT = self ::BASE - $ t ;
630
628
631
629
if ($ w > intdiv (self ::MAX_INT , $ baseMinusT )) {
632
- throw new Exception ('Integer overflow ' );
630
+ throw new \ Exception ('Integer overflow ' );
633
631
}
634
632
635
633
$ w *= $ baseMinusT ;
@@ -639,7 +637,7 @@ private static function punycodeDecode($input)
639
637
$ bias = self ::adaptBias ($ i - $ oldi , $ outPlusOne , 0 === $ oldi );
640
638
641
639
if (intdiv ($ i , $ outPlusOne ) > self ::MAX_INT - $ n ) {
642
- throw new Exception ('Integer overflow ' );
640
+ throw new \ Exception ('Integer overflow ' );
643
641
}
644
642
645
643
$ n += intdiv ($ i , $ outPlusOne );
@@ -694,15 +692,15 @@ private static function punycodeEncode($input)
694
692
}
695
693
696
694
if ($ m - $ n > intdiv (self ::MAX_INT - $ delta , $ h + 1 )) {
697
- throw new Exception ('Integer overflow ' );
695
+ throw new \ Exception ('Integer overflow ' );
698
696
}
699
697
700
698
$ delta += ($ m - $ n ) * ($ h + 1 );
701
699
$ n = $ m ;
702
700
703
701
foreach ($ iter as $ codePoint ) {
704
702
if ($ codePoint < $ n && 0 === ++$ delta ) {
705
- throw new Exception ('Integer overflow ' );
703
+ throw new \ Exception ('Integer overflow ' );
706
704
}
707
705
708
706
if ($ codePoint === $ n ) {
0 commit comments