Skip Menu |

This queue is for tickets about the IO-Socket-SSL CPAN distribution.

Report information
The Basics
Id: 67676
Status: resolved
Priority: 0/
Queue: IO-Socket-SSL

People
Owner: Nobody in particular
Requestors: GAAS [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Support IDNs using URI.pm
IO::Socket::INET can also use URI for its *{idn_to_ascii} function. Patch relative to v1.39 provided.
Subject: 0001-Support-IDNs-using-URI.pm.patch
From ef1d0f9710257852c7d643f926b1681989b36ff1 Mon Sep 17 00:00:00 2001 From: Gisle Aas <gisle@aas.no> Date: Thu, 21 Apr 2011 22:57:03 +0200 Subject: [PATCH] Support IDNs using URI.pm --- Makefile.PL | 4 ++-- SSL.pm | 4 +++- t/verify_hostname.t | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Makefile.PL b/Makefile.PL index 357f81d..2007e02 100644 --- a/Makefile.PL +++ b/Makefile.PL @@ -57,14 +57,14 @@ if ( eval { require Scalar::Util } ) { } # check if we have something which handles IDN -if ( ! eval { require Net::IDN::Encode } and ! eval { require Net::LibIDN }) { +if ( ! eval { require Net::IDN::Encode } and ! eval { require Net::LibIDN } and ! eval { require URI; URI->VERSION(1.50) }) { warn <<'EOM'; WARNING No library for handling international domain names found. It will work but croak if you try to verify an international name against a certificate. -It's recommended to install either Net::IDN::Encode or Net::LibIDN +It's recommended to install either Net::IDN::Encode, Net::LibIDN or URI EOM } diff --git a/SSL.pm b/SSL.pm index 7f7ef28..a3a508b 100644 --- a/SSL.pm +++ b/SSL.pm @@ -121,12 +121,14 @@ BEGIN { *{idn_to_ascii} = \&Net::IDN::Encode::domain_to_ascii; } elsif ( eval { require Net::LibIDN }) { *{idn_to_ascii} = \&Net::LibIDN::idn_to_ascii; + } elsif ( eval { require URI; URI->VERSION(1.50) }) { + *{idn_to_ascii} = sub { URI->new("http://" . shift)->host } } else { # default: croak if we really got an unencoded international domain *{idn_to_ascii} = sub { my $domain = shift; return $domain if $domain =~m{^[a-zA-Z0-9-_\.]+$}; - croak "cannot handle international domains, please install Net::LibIDN or Net::IDN::Encode" + croak "cannot handle international domains, please install Net::LibIDN, Net::IDN::Encode or URI" } } } diff --git a/t/verify_hostname.t b/t/verify_hostname.t index 86fd8a7..f43f77e 100644 --- a/t/verify_hostname.t +++ b/t/verify_hostname.t @@ -22,7 +22,7 @@ do "t/ssl_settings.req" || do "ssl_settings.req"; # if we have an IDN library max the IDN tests too my $can_idn = eval { require Encode } && - ( eval { require Net::LibIDN } || eval { require Net::IDN::Encode } ); + ( eval { require Net::LibIDN } || eval { require Net::IDN::Encode } || eval { require URI; URI->VERSION(1.50) } ); $|=1; my $max = 40; -- 1.6.6.rc1.31.g1a56b
Thanks for the patch. It's integrated in version 1.40 Regards, Steffen