r77056 - in /trunk/libidna-punycode-perl: Build.PL Changes LICENSE MANIFEST META.yml Makefile.PL README SIGNATURE debian/changelog lib/IDNA/Punycode.pm t/00_compile.t t/00use.t t/encode_raw.t t/encode_w-prefix.t
fabreg-guest at users.alioth.debian.org
fabreg-guest at users.alioth.debian.org
Mon Jul 4 10:07:06 UTC 2011
Author: fabreg-guest
Date: Mon Jul 4 10:07:05 2011
New Revision: 77056
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=77056
Log:
New upstream release
Added:
trunk/libidna-punycode-perl/Build.PL
- copied unchanged from r77055, branches/upstream/libidna-punycode-perl/current/Build.PL
trunk/libidna-punycode-perl/LICENSE
- copied unchanged from r77055, branches/upstream/libidna-punycode-perl/current/LICENSE
trunk/libidna-punycode-perl/META.yml
- copied unchanged from r77055, branches/upstream/libidna-punycode-perl/current/META.yml
trunk/libidna-punycode-perl/SIGNATURE
- copied unchanged from r77055, branches/upstream/libidna-punycode-perl/current/SIGNATURE
trunk/libidna-punycode-perl/t/00use.t
- copied unchanged from r77055, branches/upstream/libidna-punycode-perl/current/t/00use.t
trunk/libidna-punycode-perl/t/encode_raw.t
- copied unchanged from r77055, branches/upstream/libidna-punycode-perl/current/t/encode_raw.t
trunk/libidna-punycode-perl/t/encode_w-prefix.t
- copied unchanged from r77055, branches/upstream/libidna-punycode-perl/current/t/encode_w-prefix.t
Removed:
trunk/libidna-punycode-perl/t/00_compile.t
Modified:
trunk/libidna-punycode-perl/Changes
trunk/libidna-punycode-perl/MANIFEST
trunk/libidna-punycode-perl/Makefile.PL
trunk/libidna-punycode-perl/README
trunk/libidna-punycode-perl/debian/changelog
trunk/libidna-punycode-perl/lib/IDNA/Punycode.pm
Modified: trunk/libidna-punycode-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libidna-punycode-perl/Changes?rev=77056&op=diff
==============================================================================
--- trunk/libidna-punycode-perl/Changes (original)
+++ trunk/libidna-punycode-perl/Changes Mon Jul 4 10:07:05 2011
@@ -1,4 +1,15 @@
Revision history for Perl extension IDNA::Punycode
+
+1.100 (2011-04-15)
+ - fixed incompatibility with Net::IDN::Encode >= 1.10
+ by no longer depending on Net::IDN::Encode
+
+1.001 (2010-01-20)
+ - fixed incompability with Net::IDN::Encode >= 1.00
+
+1.000 (2010-01-20)
+ - complete rewrite based on Net::IDN::Punycode/::Encode
+ - deprecate this module, only provide it for compatibility
0.03 Thu Sep 1 14:49:17 MEST 2005
* added idn_prefix() function
Modified: trunk/libidna-punycode-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libidna-punycode-perl/MANIFEST?rev=77056&op=diff
==============================================================================
--- trunk/libidna-punycode-perl/MANIFEST (original)
+++ trunk/libidna-punycode-perl/MANIFEST Mon Jul 4 10:07:05 2011
@@ -1,5 +1,12 @@
+README
Changes
-MANIFEST This list of files
+Build.PL
Makefile.PL
+MANIFEST
lib/IDNA/Punycode.pm
-t/00_compile.t
+t/00use.t
+t/encode_raw.t
+t/encode_w-prefix.t
+LICENSE
+META.yml
+SIGNATURE Added here by Module::Build
Modified: trunk/libidna-punycode-perl/Makefile.PL
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libidna-punycode-perl/Makefile.PL?rev=77056&op=diff
==============================================================================
--- trunk/libidna-punycode-perl/Makefile.PL (original)
+++ trunk/libidna-punycode-perl/Makefile.PL Mon Jul 4 10:07:05 2011
@@ -1,9 +1,17 @@
+# Note: this file was auto-generated by Module::Build::Compat version 0.3624
use ExtUtils::MakeMaker;
-require 5.6.0;
-WriteMakefile(
- 'NAME' => 'IDNA::Punycode',
- 'VERSION_FROM' => 'lib/IDNA/Punycode.pm', # finds $VERSION
- 'PREREQ_PM' => {
- 'Test::More' => 0.32,
- },
-);
+WriteMakefile
+(
+ 'PL_FILES' => {},
+ 'INSTALLDIRS' => 'site',
+ 'NAME' => 'IDNA::Punycode',
+ 'EXE_FILES' => [],
+ 'VERSION_FROM' => 'lib/IDNA/Punycode.pm',
+ 'PREREQ_PM' => {
+ 'Test::More' => 0,
+ 'Net::IDN::Nameprep' => 1,
+ 'Net::IDN::Punycode' => 1,
+ 'Test::NoWarnings' => 0
+ }
+ )
+;
Modified: trunk/libidna-punycode-perl/README
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libidna-punycode-perl/README?rev=77056&op=diff
==============================================================================
--- trunk/libidna-punycode-perl/README (original)
+++ trunk/libidna-punycode-perl/README Mon Jul 4 10:07:05 2011
@@ -1,23 +1,30 @@
-IDNA::Punycode - conversion from IDN domain names to Punycode and back
-======================================================================
+OVERVIEW
-1. DESCRIPTION
---------------
+ IDNA::Punycode -- DEPRECATED module for IDNA and Punyode
-IDNA::Punycode will convert a domain-name from the "native" IDN
-(Internationalized Domain Name) form, i.e., a domain-name
-containing non-ASCII characters, into it's corresponding
-ACE (ASCII Compatible Encoding), and vice versa.
+INSTALLATION
-Before you do the ACE conversion, however, you must first "normalize"
-the string to convert using Net::IDN::Nameprep. See RFC3940
-(http://www.ietf.org/rfc/rfc3490.txt) for more information.
+ To install this module type the following:
-IDNA::Punycode has no dependencies.
+ perl Build.PL
+ ./Build
+ ./Build test
+ ./Build install
-2. COPYRIGHT
-------------
+DEPENDENCIES
-Copyright (c) Tatsuhiko Miyagawa <miyagawa at bulknews.net>. This program
-is free software; you can redistribute it and/or modify it under the
-same terms as Perl itself
+ This module requires these other modules and libraries:
+
+ Net::IDN::Encode (in Net-IDN-Encode)
+ Net::IDN::Punycode (in Net-IDN-Encode)
+ Net::IDN::Nameprep (indirectly)
+ Unicode::Stringprep (indirectly)
+
+AUTHOR
+
+ Claus Färber <CFAERBER at cpan.org>
+
+PREVIOUS AUTHORS
+
+ Tatsuhiko Miyagawa <miyagawa at bulknews.net>
+ Robert Urban <urban at UNIX-Beratung.de>
Modified: trunk/libidna-punycode-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libidna-punycode-perl/debian/changelog?rev=77056&op=diff
==============================================================================
--- trunk/libidna-punycode-perl/debian/changelog (original)
+++ trunk/libidna-punycode-perl/debian/changelog Mon Jul 4 10:07:05 2011
@@ -1,4 +1,4 @@
-libidna-punycode-perl (0.03-2) UNRELEASED; urgency=low
+libidna-punycode-perl (1.100-1) UNRELEASED; urgency=low
* Take overed package (see http://lists.debian.org/debian-perl/2011/07/msg00003.html).
* Added Vcs-* fields in d/control.
@@ -9,8 +9,9 @@
* Bump to 3.0 quilt format.
* Switch to DEP5 license format.
* Modified d/watch.
+ * New upstream release
- -- Fabrizio Regalli <fabreg at fabreg.it> Sat, 02 Jul 2011 01:39:24 +0200
+ -- Fabrizio Regalli <fabreg at fabreg.it> Mon, 04 Jul 2011 12:06:26 +0200
libidna-punycode-perl (0.03-1) unstable; urgency=low
Modified: trunk/libidna-punycode-perl/lib/IDNA/Punycode.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libidna-punycode-perl/lib/IDNA/Punycode.pm?rev=77056&op=diff
==============================================================================
--- trunk/libidna-punycode-perl/lib/IDNA/Punycode.pm (original)
+++ trunk/libidna-punycode-perl/lib/IDNA/Punycode.pm Mon Jul 4 10:07:05 2011
@@ -1,165 +1,87 @@
package IDNA::Punycode;
use strict;
-our $VERSION = 0.03;
+use utf8;
+use warnings;
+
+our $VERSION = "1.100";
+$VERSION = eval $VERSION;
require Exporter;
our @ISA = qw(Exporter);
-our @EXPORT = qw(encode_punycode decode_punycode idn_prefix);
+our @EXPORT = qw(encode_punycode decode_punycode idn_prefix);
-use integer;
+use Carp;
+use Net::IDN::Punycode();
+use Net::IDN::Nameprep();
+# use Net::IDN::Encode();
-our $DEBUG = 0;
our $PREFIX = 'xn--';
-
-use constant BASE => 36;
-use constant TMIN => 1;
-use constant TMAX => 26;
-use constant SKEW => 38;
-use constant DAMP => 700;
-use constant INITIAL_BIAS => 72;
-use constant INITIAL_N => 128;
-
-my $Delimiter = chr 0x2D;
-my $BasicRE = qr/[\x00-\x7f]/;
-
-sub _croak { require Carp; Carp::croak(@_); }
sub idn_prefix {
$PREFIX = shift;
}
-sub digit_value {
- my $code = shift;
- return ord($code) - ord("A") if $code =~ /[A-Z]/;
- return ord($code) - ord("a") if $code =~ /[a-z]/;
- return ord($code) - ord("0") + 26 if $code =~ /[0-9]/;
- return;
+# These functions are copied from Net::IDN::Encode. This allows us to optimise
+# Net::IDN::Encode for the static prefix (e.g. by using /o), while we continue
+# to support changing the prefix here.
+
+sub _to_ascii {
+ use bytes;
+ no warnings qw(utf8); # needed for perl v5.6.x
+
+ my $label = shift;
+
+ if($label =~ m/[^\x00-\x7F]/) {
+ $label = Net::IDN::Nameprep::nameprep($label);
+ croak 'Invalid label (toASCII, step 5)' if $label =~ m/^$PREFIX/i;
+ $label = $PREFIX.(Net::IDN::Punycode::encode_punycode($label));
+ }
+
+ croak 'Invalid label length (toASCII, step 8)' if
+ length($label) < 1 ||
+ length($label) > 63;
+
+ return $label;
}
-sub code_point {
- my $digit = shift;
- return $digit + ord('a') if 0 <= $digit && $digit <= 25;
- return $digit + ord('0') - 26 if 26 <= $digit && $digit <= 36;
- die 'NOT COME HERE';
-}
+sub _to_unicode {
+ use bytes;
-sub adapt {
- my($delta, $numpoints, $firsttime) = @_;
- $delta = $firsttime ? $delta / DAMP : $delta / 2;
- $delta += $delta / $numpoints;
- my $k = 0;
- while ($delta > ((BASE - TMIN) * TMAX) / 2) {
- $delta /= BASE - TMIN;
- $k += BASE;
- }
- return $k + (((BASE - TMIN + 1) * $delta) / ($delta + SKEW));
+ my $label = shift;
+ my $result = $label;
+
+ eval {
+ if($label =~ m/[^\x00-\x7F]/) {
+ $label = Net::IDN::Nameprep::nameprep($label);
+ }
+
+ my $save3 = $label;
+ croak 'Missing IDNA prefix (ToUnicode, step 3)' unless $label =~ s/^$PREFIX//i;
+ $label = Net::IDN::Punycode::decode_punycode($label);
+
+ my $save6 = _to_ascii($label);
+ croak 'Invalid label (ToUnicode, step 7)' unless uc($save6) eq uc($save3);
+ $result = $label;
+ };
+
+ return $result;
}
sub decode_punycode {
- my $code = shift;
-
- my $n = INITIAL_N;
- my $i = 0;
- my $bias = INITIAL_BIAS;
- my @output;
-
if ($PREFIX) {
- if ($code !~ /^$PREFIX/) {
- return $code;
- }
- $code =~ s/^$PREFIX//;
+ return _to_unicode(shift);
+ } else {
+ return Net::IDN::Punycode::decode_punycode(shift);
}
-
- if ($code =~ s/(.*)$Delimiter//o) {
- push @output, map ord, split //, $1;
- return _croak('non-basic code point') unless $1 =~ /^$BasicRE*$/o;
- }
-
- while ($code) {
- my $oldi = $i;
- my $w = 1;
- LOOP:
- for (my $k = BASE; 1; $k += BASE) {
- my $cp = substr($code, 0, 1, '');
- my $digit = digit_value($cp);
- defined $digit or return _croak("invalid punycode input");
- $i += $digit * $w;
- my $t = ($k <= $bias) ? TMIN
- : ($k >= $bias + TMAX) ? TMAX : $k - $bias;
- last LOOP if $digit < $t;
- $w *= (BASE - $t);
- }
- $bias = adapt($i - $oldi, @output + 1, $oldi == 0);
- warn "bias becomes $bias" if $DEBUG;
- $n += $i / (@output + 1);
- $i = $i % (@output + 1);
- splice(@output, $i, 0, $n);
- warn join " ", map sprintf('%04x', $_), @output if $DEBUG;
- $i++;
- }
- return join '', map chr, @output;
}
sub encode_punycode {
- my $input = shift;
- # my @input = split //, $input; # doesn't work in 5.6.x!
- my @input = map substr($input, $_, 1), 0..length($input)-1;
-
- my $n = INITIAL_N;
- my $delta = 0;
- my $bias = INITIAL_BIAS;
-
- my @output;
- my @basic = grep /$BasicRE/, @input;
- my $h = my $b = @basic;
- #push @output, @basic, $Delimiter if $b > 0;
- push @output, @basic if $b > 0;
- warn "basic codepoints: (@output)" if $DEBUG;
-
- if ($h < @input) {
- $PREFIX && unshift(@output, $PREFIX);
- push(@output, $Delimiter);
+ if ($PREFIX) {
+ return _to_ascii(shift);
} else {
- return join '', @output;
+ return Net::IDN::Punycode::encode_punycode(shift);
}
-
- while ($h < @input) {
- my $m = min(grep { $_ >= $n } map ord, @input);
- warn sprintf "next code point to insert is %04x", $m if $DEBUG;
- $delta += ($m - $n) * ($h + 1);
- $n = $m;
- for my $i (@input) {
- my $c = ord($i);
- $delta++ if $c < $n;
- if ($c == $n) {
- my $q = $delta;
- LOOP:
- for (my $k = BASE; 1; $k += BASE) {
- my $t = ($k <= $bias) ? TMIN :
- ($k >= $bias + TMAX) ? TMAX : $k - $bias;
- last LOOP if $q < $t;
- my $cp = code_point($t + (($q - $t) % (BASE - $t)));
- push @output, chr($cp);
- $q = ($q - $t) / (BASE - $t);
- }
- push @output, chr(code_point($q));
- $bias = adapt($delta, $h + 1, $h == $b);
- warn "bias becomes $bias" if $DEBUG;
- $delta = 0;
- $h++;
- }
- }
- $delta++;
- $n++;
- }
- return join '', @output;
-}
-
-sub min {
- my $min = shift;
- for (@_) { $min = $_ if $_ <= $min }
- return $min;
}
1;
@@ -167,74 +89,89 @@
=head1 NAME
-IDNA::Punycode - encodes Unicode string in Punycode
-
-=head1 SYNOPSIS
-
- use IDNA::Punycode;
- idn_prefix('xn--');
- $punycode = encode_punycode($unicode);
- $unicode = decode_punycode($punycode);
+IDNA::Punycode - DEPRECATED module for IDNA and Punyode
=head1 DESCRIPTION
-IDNA::Punycode is a module to encode / decode Unicode strings into
-Punycode, an efficient encoding of Unicode for use with IDNA.
+This module is deprecated.
-This module requires Perl 5.6.0 or over to handle UTF8 flagged Unicode
-strings.
+Please use L<Net::IDN::Encode> to handle full domain names and
+L<Net::IDN::Punycode> for raw I<Punycode> encoding.
+
+This module is provided for compatibility with earlier versions of
+C<IDNA::Punycode>.
=head1 FUNCTIONS
-This module exports following functions by default.
+The following functions are imported by default. If you also C<use Net::IDN::Punycode>,
+be sure to disable import from this module:
-=over 4
+ use IDNA::Punycode();
-=item encode_punycode
+=over
- $punycode = encode_punycode($unicode);
+=item idn_prefix($prefix)
-takes Unicode string (UTF8-flagged variable) and returns Punycode
-encoding for it.
+Sets C<$IDNA::Punycode::PREFIX> to C<$prefix>.
-=item decode_punycode
+B<Do not use this function> in larger applications or environments
+in which multiple application share global variables (such as
+L<mod_perl>). Instead, set the variable locally:
- $unicode = decode_punycode($punycode)
+ local $IDNA::Punycode::PREFIX = 'yo--';
-takes Punycode encoding and returns original Unicode string.
+=item encode_punycode($input)
-=item idn_prefix
+If C<$IDNA::Punycode::PREFIX> is C<''>, encodes C<$input> with
+Punycode.
- idn_prefix($prefix);
+If C<$IDNA::Punycode::PREFIX> is not C<''>, encodes C<$input> with
+Punycode and adds the prefix if C<$input> does contain non-base
+characters (S<i. e.> characters above U+007F). If C<$input> does
+not contain any non-base characters, it is returned as-is.
-causes encode_punycode() to add $prefix to ACE-string after conversion.
-As a side-effect decode_punycode() will only consider strings
-beginning with $prefix as punycode representations.
+This function does not do any string preparation as specified by
+I<nameprep> or other I<stringprep> profiles. Use
+L<Net::IDN::Encode> if you just want to convert a domain name.
-According to RFC 3490 the ACE prefix "xn--" had been chosen as the
-standard. Thus, "xn--" is also the default ACE prefix. For compatibility
-I'm leaving idn_prefix() in the module. Use C<idn_prefix(undef)> to
-get the old behaviour.
+This function will croak on invalid input.
+
+=item decode_punycode($input)
+
+If C<$IDNA::Punycode::PREFIX> is C<''>, decodes C<$input> with
+Punycode.
+
+If C<$IDNA::Punycode::PREFIX> is not C<''>, checks whether
+C<$input> starts with the prefix. If C<$input> starts with the
+prefix, the prefix is removed and the remainder is decoded with
+Punycode. If C<$input> does not start with the prefix, it is
+returned as-is.
+
+Of course, this function does not do any string preparation as
+specified by I<nameprep> or other I<stringprep> profiles (or some
+sort of de-preparation).
+
+This function will croak on invalid input.
=back
-These functions throws exceptionsn on failure. You can catch 'em via
-C<eval>.
-
=head1 AUTHORS
-Tatsuhiko Miyagawa E<lt>miyagawa at bulknews.netE<gt> is the original
-author and wrote almost all the code.
+Claus FE<auml>rber <CFAERBER at cpan.org>
-Robert Urban E<lt>urban at UNIX-Beratung.deE<gt> added C<idn_prefix()>.
+Previous version written by Tatsuhiko Miyagawa E<lt>miyagawa at bulknews.netE<gt>
+and extended by Robert Urban E<lt>urban at UNIX-Beratung.deE<gt>.
+
+=head1 LICENSE
+
+Copyright 2007-2010 Claus FE<auml>rber.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 SEE ALSO
-http://www.ietf.org/internet-drafts/draft-ietf-idn-punycode-01.txt
-
-L<Encode::Punycode>
+L<Encode>, L<Net::IDN::Encode>, L<Net::IDN::Punycode>,
+S<RFC 3492> (L<http://www.ietf.org/rfc/rfc3492.txt>)
=cut
More information about the Pkg-perl-cvs-commits
mailing list