]> git.ipfire.org Git - thirdparty/AWStats.git/commitdiff
Prepare code for DecodePunycode feature.
authorLaurent Destailleur <eldy@destailleur.fr>
Fri, 21 Mar 2014 18:08:32 +0000 (19:08 +0100)
committerLaurent Destailleur <eldy@destailleur.fr>
Fri, 21 Mar 2014 18:08:32 +0000 (19:08 +0100)
wwwroot/cgi-bin/awstats.pl

index 8e70e9dfb65b16c5aeba1e1e39b3b83bef07e7a6..f3a9d46f57e892287cf34b2596785e82ac3fb8b8 100755 (executable)
@@ -192,7 +192,7 @@ use vars qw/
   $IncludeInternalLinksInOriginSection
   $AuthenticatedUsersNotCaseSensitive
   $Expires $UpdateStats $MigrateStats $URLNotCaseSensitive $URLWithQuery $URLReferrerWithQuery
-  $DecodeUA
+  $DecodeUA $DecodePunycode
   /;
 (
        $DebugMessages,
@@ -237,11 +237,12 @@ use vars qw/
        $URLNotCaseSensitive,
        $URLWithQuery,
        $URLReferrerWithQuery,
-       $DecodeUA
+       $DecodeUA,
+       $DecodePunycode
   )
   = (
        0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+       0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
   );
 use vars qw/
   $DetailedReportsOnNewWindows
@@ -1935,6 +1936,26 @@ sub Parse_Config {
 
                        # No regex test as SiteDomain is always exact value
                        $SiteDomain = $value;
+
+                       if ($SiteDomain =~ m/xn--/) 
+                       {
+                               # TODO Add code to test if IDNA::Punycode module is on
+                               #use IDNA::Punycode;
+                               $DecodePunycode=0;      # Set to 1 if module is on      
+                               if ($DecodePunycode)
+                               {
+                       idn_prefix(undef);
+                       my @parts = split(/\./, $SiteDomain);
+                       foreach (@parts) {
+                               if ($_ =~ s/^xn--//) {
+                               eval { $_ = decode_punycode($_); };
+                               if (my $e = $@) { $_ = $e; }
+                           }
+                       }
+                       $SiteDomain = join('.', @parts);
+                               }
+            }
+                                               
                        next;
                }
                if ( $param =~ /^AddLinkToExternalCGIWrapper/ ) {