From: Laurent Destailleur Date: Fri, 21 Mar 2014 18:08:32 +0000 (+0100) Subject: Prepare code for DecodePunycode feature. X-Git-Tag: AWSTATS_7_4~18^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=15ba8551d787adc2ca6707a8ace8d92855d72e7c;p=thirdparty%2FAWStats.git Prepare code for DecodePunycode feature. --- diff --git a/wwwroot/cgi-bin/awstats.pl b/wwwroot/cgi-bin/awstats.pl index 8e70e9df..f3a9d46f 100755 --- a/wwwroot/cgi-bin/awstats.pl +++ b/wwwroot/cgi-bin/awstats.pl @@ -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/ ) {