Net-IDN-Encode-1.000/000075500000000000000000000000001135223703100140365ustar00rootroot00000000000000Net-IDN-Encode-1.000/Build.PL000064400000000000000000000013031135223703100153270ustar00rootroot00000000000000use 5.006; use strict; use utf8; use Module::Build; my $b = Module::Build->new( 'module_name' => 'Net::IDN::Encode', 'license' => 'perl', 'dist_author' => 'Claus Färber ', 'dist_abstract' => 'Internationalizing Domain Names in Applications (RFC 3490)', 'sign' => 1, 'create_license' => 1, 'create_makefile_pl' => 'traditional', 'requires' => { 'Net::IDN::Nameprep' => 1, }, 'build_requires' => { 'Test::More' => 0, 'Test::NoWarnings' => 0, }, 'no_index' => { 'directory' => 'eg' }, 'resources' => { 'homepage' => 'http://search.cpan.org/dist/Net-IDN-Encode', 'repository' => 'http://github.com/cfaerber/Net-IDN-Encode', }, ); $b->create_build_script; Net-IDN-Encode-1.000/Changes000064400000000000000000000036371135223703100153420ustar00rootroot00000000000000Revision history for Perl extension Net::IDN::Encode 1.000 (2010-01-13) - clean-up - release 0.999_20090112 (2010-01-10) - add XS for decode_punycode 0.999_20090110 (2010-01-10) - add XS for encode_punycode - include Net::IDN::Nameprep into Net::IDN::Encode *sigh* - drop IDNA::Punycode 0.99_20091231 - depend on perl 5.8.3 - optimise Net::IDN::Punycode 0.99_20091226 Sat Dec 26 00:00:00 2009 - some clean-ups 0.99_20091216 Wed Dec 16 00:00:00 2009 - switch to Module::Build - switch to Github, remove svn:keywords, add .gitignore - use ASCII in POD, fixes FAILs with perl 5.6.x - add examples in eg/ 0.99_20080913 Sun Sep 13 12:00:00 2008 - fixed perl 5.6.x (no warnings 'utf8') 0.99_20080913 Sat Sep 13 12:00:00 2008 - require perl version 5.6.0 instead of 5.6.6 - skip more tests in lower perl versions - removed Encode::Punycode; Encode is only available from perl 5.7.3 - renamed back to Net::IDN::Encode; without Encode::Punycode, the new name does not make sense. 0.99_20071012 Fri Oct 12 12:00:00 2007 - renamed Net-IDN-Encode distribution to Net-IDN-tools - includes Net::IDN::Punycode (from IDNA::Punycode v0.02) - includes Net::IDN::Nameprep (complete rewrite, uses Unicode::Stringprep) - includes IDNA::Punycode (deprecated, new version based on Net::IDN::Punycode/::Encode) - includes Encode::Punycode (new version based on Net::IDN::Punycode) - uses Unicode::Stringprep - more tests, including test vectors from Internet Draft draft-josefsson-idn-test-vectors-00. - FIXES: #16150: Net::IDN::Encode depends on non-modulelist module IDNA::Punycode - FIXES: #16145: IDNA::Punycode 0.03 - FIXES: #28123: Undeclared dependency on Unicode::String (reported by ANDK) - FIXES WARNING: v-string in use/require non-portable (Net::IDN::Nameprep[::*]) 0.02 Sun Jun 20 00:00:00 2004 - fixed handling of incomplete/empty email addresses 0.01 Sun May 30 00:00:00 2004 - first release Net-IDN-Encode-1.000/LICENSE000064400000000000000000000436101135223703100150470ustar00rootroot00000000000000This software is copyright (c) 2010 by Claus Färber . This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2010 by Claus Färber . This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2010 by Claus Färber . This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End Net-IDN-Encode-1.000/MANIFEST000064400000000000000000000004761135223703100151760ustar00rootroot00000000000000README Changes Build.PL Makefile.PL MANIFEST eg/hello_idn.pl eg/hello_idn_email.pl lib/Net/IDN/Encode.pm lib/Net/IDN/Punycode.pm lib/Net/IDN/Punycode.xs lib/Net/IDN/Punycode/PP.pm t/00use.t t/encode_bytes.t t/encode_utf8.t t/punycode_vec.t t/punycode_vec-pp.t LICENSE META.yml SIGNATURE Added here by Module::Build Net-IDN-Encode-1.000/META.yml000064400000000000000000000013521135223703100153100ustar00rootroot00000000000000--- name: Net-IDN-Encode version: 1.000 author: - 'Claus Färber ' abstract: Internationalizing Domain Names in Applications (RFC 3490) license: perl resources: license: http://dev.perl.org/licenses/ build_requires: Test::More: 0 Test::NoWarnings: 0 requires: Net::IDN::Nameprep: 1 configure_requires: Module::Build: 0.35 provides: Net::IDN::Encode: file: lib/Net/IDN/Encode.pm version: 1.000 Net::IDN::Punycode: file: lib/Net/IDN/Punycode.pm version: 1.000 Net::IDN::Punycode::PP: file: lib/Net/IDN/Punycode/PP.pm version: 1.000 no_index: directory: eg generated_by: Module::Build version 0.35 meta-spec: url: http://module-build.sourceforge.net/META-spec-v1.4.html version: 1.4 Net-IDN-Encode-1.000/Makefile.PL000064400000000000000000000010061135223703100160050ustar00rootroot00000000000000# Note: this file was auto-generated by Module::Build::Compat version 0.35 use ExtUtils::MakeMaker; WriteMakefile ( 'PL_FILES' => {}, 'INSTALLDIRS' => 'site', 'NAME' => 'Net::IDN::Encode', 'EXE_FILES' => [], 'VERSION_FROM' => 'lib/Net/IDN/Encode.pm', 'PREREQ_PM' => { 'Test::More' => 0, 'Net::IDN::Nameprep' => 1, 'Test::NoWarnings' => 0 } ) ; Net-IDN-Encode-1.000/README000064400000000000000000000011651135223703100147210ustar00rootroot00000000000000OVERVIEW Net::IDN::Encode -- high-level interface for encoding and decoding of domain names (implements toASCII and toUNICODE as defined in RFC 3490) Net::IDN::Punycode -- ASCII-compatible encoding of Unicode (Punycode, RFC 3492) INSTALLATION To install this module type the following: perl Build.PL ./Build ./Build test ./Build install DEPENDENCIES This module requires these other modules and libraries: Unicode::Stringprep AUTHOR Claus Färber ACKNOWLEDGMENTS Tatsuhiko Miyagawa Robert Urban Net-IDN-Encode-1.000/SIGNATURE000064400000000000000000000034521135223703100153260ustar00rootroot00000000000000This file contains message digests of all files listed in MANIFEST, signed via the Module::Signature module, version 0.61. To verify the content in this distribution, first make sure you have Module::Signature installed, then type: % cpansign -v It will check each file's integrity, as well as the signature's validity. If "==> Signature verified OK! <==" is not displayed, the distribution may already have been compromised, and you should not run its Makefile.PL or Build.PL. -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 SHA1 474fce1ed2e38f3c705a8cc599e490b7ed3a71f8 Build.PL SHA1 aeb66bc352b63cca3c610098d84fe07d5accd92c Changes SHA1 9b37c74ac55bf4a1d347a873f9936ca24cab4f3b LICENSE SHA1 99f331c7ec6f8d266c61f48a406675280826e743 MANIFEST SHA1 3e31ef79fb9475083e0b474e7852e8a9ec84fd2b META.yml SHA1 885f6e35ca0192ceff0f9c9aefbffb01a99ed545 Makefile.PL SHA1 a9bd2da838ae590561da7e3bfcbf5070a00df91d README SHA1 c7825316b854216c50a88b5750c3a08a91e56695 eg/hello_idn.pl SHA1 da626e4a67218dc2ed50b4a5b45b258078db0681 eg/hello_idn_email.pl SHA1 927d42e12ff801252835f44972439d6fddaed1e1 lib/Net/IDN/Encode.pm SHA1 c7eb9bb6f7e7fa689c036b2652468f8a3262a755 lib/Net/IDN/Punycode.pm SHA1 27ca89ca67dd1658680a51d4127956dcd8939374 lib/Net/IDN/Punycode.xs SHA1 b70ce6aa2f1c6c74835bc9fbc74c57fc03ea228a lib/Net/IDN/Punycode/PP.pm SHA1 2bba22129594f3cca49c30412b87943c20da2e61 t/00use.t SHA1 659313cde51535a32053b02c07991da57725c214 t/encode_bytes.t SHA1 ae0cbfa0e7dc67decc291775b8ebcb7a01c76311 t/encode_utf8.t SHA1 ae777d8162fdfe9aa45d7f025ea3aafbdd029b74 t/punycode_vec-pp.t SHA1 bc123a000764e2c8f5a2ee94f3365dfe69a7e070 t/punycode_vec.t -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (Darwin) iEYEARECAAYFAktW62EACgkQSKUOY2OWgPDQeACdF8bR1bCN1dhxSJo9U8cAro11 SQUAnRHotX+3PaIN52bk4sL2SHf5yJjE =sXAt -----END PGP SIGNATURE----- Net-IDN-Encode-1.000/eg/000075500000000000000000000000001135223703100144315ustar00rootroot00000000000000Net-IDN-Encode-1.000/eg/hello_idn.pl000064400000000000000000000004201135223703100167170ustar00rootroot00000000000000#!/usr/bin/perl use strict; use utf8; binmode STDOUT, ":utf8"; use Net::IDN::Encode; my @domain = ( '例.テスト', 'müller.example.net', ); foreach (@domain) { printf "%s: toASCII=<%s>, toUnicode=<%s>\n", $_, domain_to_ascii($_), domain_to_unicode($_); } Net-IDN-Encode-1.000/eg/hello_idn_email.pl000064400000000000000000000004361135223703100200750ustar00rootroot00000000000000#!/usr/bin/perl use strict; use utf8; binmode STDOUT, ":utf8"; use Net::IDN::Encode; my @email = ( 'postmaster@例.テスト', 'infoï¼ müller.example.net', ); foreach (@email) { printf "%s: toASCII=<%s>, toUnicode=<%s>\n", $_, email_to_ascii($_), email_to_unicode($_); } Net-IDN-Encode-1.000/lib/000075500000000000000000000000001135223703100146045ustar00rootroot00000000000000Net-IDN-Encode-1.000/lib/Net/000075500000000000000000000000001135223703100153325ustar00rootroot00000000000000Net-IDN-Encode-1.000/lib/Net/IDN/000075500000000000000000000000001135223703100157445ustar00rootroot00000000000000Net-IDN-Encode-1.000/lib/Net/IDN/Encode.pm000064400000000000000000000161151135223703100175030ustar00rootroot00000000000000package Net::IDN::Encode; use strict; use utf8; use warnings; our $VERSION = "1.000"; $VERSION = eval $VERSION; use Carp; use Exporter; use Net::IDN::Nameprep 1 (); use Net::IDN::Punycode 1 (); our @ISA = ('Exporter'); our @EXPORT = (); our @EXPORT_OK = ( 'to_ascii', 'to_unicode', 'domain_to_ascii', 'domain_to_unicode', 'email_to_ascii', 'email_to_unicode', ); our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK ); our $IDNA_prefix = 'xn--'; sub to_ascii { use bytes; no warnings qw(utf8); # needed for perl v5.6.x my ($label,%param) = @_; if($label =~ m/[^\x00-\x7F]/) { $label = Net::IDN::Nameprep::nameprep($label); } if($param{'UseSTD3ASCIIRules'}) { croak 'Invalid domain name (toASCII, step 3)' if $label =~ m/^-/ || $label =~ m/-$/ || $label =~ m/[\x00-\x2C\x2E-\x2F\x3A-\x40\x5B-\x60\x7B-\x7F]/; } if($label =~ m/[^\x00-\x7F]/) { croak 'Invalid label (toASCII, step 5)' if $label =~ m/^$IDNA_prefix/; return $IDNA_prefix.(Net::IDN::Punycode::encode_punycode($label)); } else { return $label; } } sub to_unicode { use bytes; my ($label,%param) = @_; my $orig = $label; return eval { if($label =~ m/[^\x00-\x7F]/) { $label = _nameprep($label); } my $save3 = $label; die unless $label =~ s/^$IDNA_prefix//; $label = Net::IDN::Punycode::decode_punycode($label); my $save6 = to_ascii($label,%param); die unless uc($save6) eq uc($save3); $label; } || $orig; } sub _domain { use utf8; my ($domain,$to_function,@param) = @_; return $domain if !defined($domain) || $domain eq ''; return join '.', grep { croak 'Invalid domain name' if length($_) > 63 && !m/[^\x00-\x7F]/; 1 } map { $to_function->($_, @param, 'UseSTD3ASCIIRules' => 1) } split /[\.。.。]/, $domain; } sub _email { use utf8; my ($email,$to_function,@param) = @_; return $email if !defined($email) || $email eq ''; $email =~ m/^([^"\@ï¼ ]+|"(?:(?:[^"]|\\.)*[^\\])?")(?:[\@ï¼ ] (?:([^\[\]]*)|(\[.*\]))?)?$/x || croak "Invalid email address"; my($local_part,$domain,$domain_literal) = ($1,$2,$3); $local_part =~ m/[^\x00-\x7F]/ && croak "Invalid email address"; $domain_literal =~ m/[^\x00-\x7F]/ && croak "Invalid email address" if $domain_literal; $domain = _domain($domain,$to_function,@param) if $domain; return ($domain || $domain_literal) ? ($local_part.'@'.($domain || $domain_literal)) : ($local_part); } sub domain_to_ascii { _domain(shift,\&to_ascii) } sub domain_to_unicode { _domain(shift,\&to_unicode) } sub email_to_ascii { _email(shift,\&to_ascii) } sub email_to_unicode { _email(shift,\&to_unicode) } use Unicode::Stringprep; use Unicode::Stringprep::Mapping; use Unicode::Stringprep::Prohibited; ## NB: Do not rely on this function being here. It will go away with IDNA2008. ## If you need a separate nameprep, use Net::IDN::Nameprep (when it's fixed). ## *_nameprep = Unicode::Stringprep->new( 3.2, [ @Unicode::Stringprep::Mapping::B1, @Unicode::Stringprep::Mapping::B2 ], 'KC', [ @Unicode::Stringprep::Prohibited::C12, @Unicode::Stringprep::Prohibited::C22, @Unicode::Stringprep::Prohibited::C3, @Unicode::Stringprep::Prohibited::C4, @Unicode::Stringprep::Prohibited::C5, @Unicode::Stringprep::Prohibited::C6, @Unicode::Stringprep::Prohibited::C7, @Unicode::Stringprep::Prohibited::C8, @Unicode::Stringprep::Prohibited::C9 ], 1, ); 1; __END__ =encoding utf8 =head1 NAME Net::IDN::Encode - Internationalizing Domain Names in Applications (S) =head1 SYNOPSIS use Net::IDN::Encode ':all'; my $a = domain_to_ascii("müller.example.org"); my $e = email_to_ascii("POSTMASTER@例。テスト"); my $u = domain_to_unicode('EXAMPLE.XN--11B5BS3A9AJ6G'); =head1 DESCRIPTION This module provides an easy-to-use interface for encoding and decoding Internationalized Domain Names (IDNs). IDNs use characters drawn from a large repertoire (Unicode), but IDNA allows the non-ASCII characters to be represented using only the ASCII characters already allowed in so-called host names today (letter-digit-hypen, C). =head1 FUNCTIONS By default, this module does not export any subroutines. You may use the C<:all> tag to import everything. You can also use regular expressions such as C or C to select some of the functions, see L for details. The following functions are available: =over =item to_ascii( $label [, 'UseSTD3ASCIIRules' => 1 ] ) Converts a single label C<$label> to ASCII. Will throw an exception on invalid input. This function takes the following parameter: =over =item UseSTD3ASCIIRules (boolean) If set to a true value, checks the label for compliance with S (S) syntax for host name parts. =back This function does not try to handle strings that consist of multiple lables (such as domain names). =item to_unicode( $label ) Converts a single label C<$label> to Unicode. Will throw an exception on invalid input. This function does not try to handle strings that consist of multiple lables (such as domain names). =item domain_to_unicode( $domain ) Converts all labels of the hostname C<$domain> (with labels seperated by dots) to Unicode. Will throw an exception on invalid input. =item domain_to_ascii( $domain ) Converts all labels of the hostname C<$domain> (with labels seperated by dots) to ASCII. Will throw an exception on invalid input. The following characters are recognized as dots: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61 (halfwidth ideographic full stop). =item domain_to_unicode( $domain ) Converts all labels of the hostname C<$domain> (with labels seperated by dots) to Unicode. Will throw an exception on invalid input. The following characters are recognized as dots: U+002E (full stop), U+3002 (ideographic full stop), U+FF0E (fullwidth full stop), U+FF61 (halfwidth ideographic full stop). =item email_to_ascii( $email ) Converts the domain part (right hand side, separated by an at sign) of the S/2822 email address to ASCII. May throw an exception on invalid input. This function currently does not handle internationalization of the local-part (left hand side). This may change in future versions. The follwing characters are recognized as at signs: U+0040 (commercial at), U+FF20 (fullwidth commercial at). =item email_to_unicode( $email ) Converts the domain part (right hand side, separated by an at sign) of the S/2822 email address to Unicode. May throw an exception on invalid input. This function currently does not handle internationalization of the local-part (left hand side). This may change in future versions. The follwing characters are recognized as at signs: U+0040 (commercial at), U+FF20 (fullwidth commercial at). =back =head1 AUTHOR Claus FErber =head1 LICENSE Copyright 2007-2010 Claus FErber. This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO L, L, S (L) =cut Net-IDN-Encode-1.000/lib/Net/IDN/Punycode.pm000064400000000000000000000042171135223703100200740ustar00rootroot00000000000000package Net::IDN::Punycode; use 5.006; use strict; use utf8; use warnings; use Exporter; our $VERSION = "1.000"; our @ISA = qw(Exporter); our @EXPORT = (); our @EXPORT_OK = qw(encode_punycode decode_punycode); our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK ); eval { require XSLoader; XSLoader::load('Net::IDN::Punycode'); }; if (!defined(&encode_punycode)) { require Net::IDN::Punycode::PP; Net::IDN::Punycode::PP->import(qw(:all)); } 1; __END__ =head1 NAME Net::IDN::Punycode - A Bootstring encoding of Unicode for IDNA (S) =head1 SYNOPSIS use Net::IDN::Punycode qw(:all); $punycode = encode_punycode($unicode); $unicode = decode_punycode($punycode); =head1 DESCRIPTION This module implements the Punycode encoding. Punycode is an instance of a more general algorithm called Bootstring, which allows strings composed from a small set of "basic" code points to uniquely represent any string of code points drawn from a larger set. Punycode is Bootstring with particular parameter values appropriate for IDNA. Note that this module does not do any string preparation as specified by I/I. It does not do add any prefix or suffix, either. =head1 FUNCTIONS No functions are exported by default. You can use the tag C<:all> or import them individually. The following functions are available: =over 4 =item encode_punycode($input) Decodes C<$input> with Punycode and returns the result. This function will throw an exception on invalid input. =item decode_punycode($input) Decodes C<$input> with Punycode and returns the result. This function will throw an exception on invalid input. =back =head1 AUTHORS Tatsuhiko Miyagawa Emiyagawa@bulknews.netE (versions 0.01 to 0.02) Claus FErber ECFAERBER@cpan.orgE (from version 1.00) =head1 LICENSE Copyright 2002-2004 Tatsuhiko Miyagawa Emiyagawa@bulknews.netE Copyright 2007-2010 Claus FErber ECFAERBER@cpan.orgE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO S (L), L, L =cut Net-IDN-Encode-1.000/lib/Net/IDN/Punycode.xs000064400000000000000000000146711135223703100201170ustar00rootroot00000000000000#include "EXTERN.h" #include "perl.h" #include "XSUB.h" #define BASE 36 #define TMIN 1 #define TMAX 26 #define SKEW 38 #define DAMP 700 #define INITIAL_BIAS 72 #define INITIAL_N 128 #define isBASE(x) UTF8_IS_INVARIANT((unsigned char)x) #define DELIM '-' #define TMIN_MAX(t) (((t) < TMIN) ? (TMIN) : ((t) > TMAX) ? (TMAX) : (t)) static char enc_digit[BASE] = { 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', }; static UV dec_digit[0x80] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 00..0F */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 10..1F */ -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, /* 20..2F */ 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, -1, -1, -1, -1, -1, -1, /* 30..3F */ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 40..4F */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 50..5F */ -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, /* 60..6F */ 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1, /* 70..7F */ }; static int adapt(int delta, int numpoints, int first) { int k; delta /= first ? DAMP : 2; delta += delta/numpoints; for(k=0; delta > ((BASE-TMIN) * TMAX)/2; k += BASE) delta /= BASE-TMIN; return k + (((BASE-TMIN+1) * delta) / (delta+SKEW)); }; MODULE = Net::IDN::Punycode PACKAGE = Net::IDN::Punycode SV* encode_punycode(input) SV * input PREINIT: UV c, m, n = INITIAL_N; int k, q, t; int bias = INITIAL_BIAS; int delta = 0, skip_delta; char *in_s, *in_p, *in_e, *re_s, *re_p, *re_e, *skip_p; int first = 1; STRLEN h, remain; STRLEN length_guess, u8; PPCODE: if(!SvOK(input)) XSRETURN_UNDEF; length_guess = sv_utf8_upgrade(input); in_s = in_p = SvPV_nolen(input); in_e = SvEND(input); /* copy basic code points */ if(length_guess < 64) length_guess = 64; /* optimise for maximum length of domain names */ length_guess += 2; /* plus DELIM + '\0' */ RETVAL = NEWSV('P',length_guess); sv_2mortal(RETVAL); /* so we can use croak w/o memory leaks */ SvPOK_only(RETVAL); /* UTF8 is off (BASE chars only) */ re_s = re_p = SvPV_nolen(RETVAL); re_e = re_s + SvLEN(RETVAL); while(in_p < in_e) { if( isBASE(*in_p) ) *re_p++ = *in_p; in_p++; } h = re_p - re_s; /* add DELIM if needed */ if(h) *re_p++ = DELIM; for(;;) { /* find smallest code point not yet handled */ m = UV_MAX; q = skip_delta = 0; for(in_p = skip_p = in_s; in_p < in_e;) { c = utf8_to_uvuni(in_p, &u8); if(c >= n && c < m) { m = c; skip_p = in_p; skip_delta = q; } if(c < n) ++q; in_p += u8; } if(m == UV_MAX) break; /* increase delta to the state corresponding to the m code point at the beginning of the string */ delta += (m-n) * (h+1); n = m; /* now find the chars to be encoded in this round */ delta += skip_delta; for(in_p = skip_p; in_p < in_e;) { c = utf8_to_uvuni(in_p, &u8); if(c < n) { ++delta; } else if( c == n ) { q = delta; for(k = BASE;; k += BASE) { if(re_p >= re_e) { length_guess = re_e - re_s + 16; re_e = SvGROW(RETVAL, length_guess); re_p = re_e + (re_p - re_s); re_s = re_e; re_e = re_s + length_guess; } t = TMIN_MAX(k - bias); if(q < t) break; *re_p++ = enc_digit[t + ((q-t) % (BASE-t))]; q = (q-t) / (BASE-t); } if(q > BASE) croak("input exceeds punycode limit"); *re_p++ = enc_digit[q]; bias = adapt(delta, h+1, first); delta = first = 0; ++h; --remain; } in_p += u8; } ++delta; ++n; } *re_p = 0; SvCUR_set(RETVAL, re_p - re_s); ST(0) = RETVAL; XSRETURN(1); SV* decode_punycode(input) SV * input PREINIT: UV c, n = INITIAL_N; int i = 0, oldi, j, k, t, w; int bias = INITIAL_BIAS; int delta = 0, skip_delta; char *in_s, *in_p, *in_e, *re_s, *re_p, *re_e, *skip_p; int first = 1; STRLEN length_guess, h, u8; PPCODE: if(!SvOK(input)) XSRETURN_UNDEF; in_s = in_p = SvPV_nolen(input); in_e = SvEND(input); length_guess = SvCUR(input); length_guess *= 2; if(length_guess < 256) length_guess = 256; RETVAL = NEWSV('D',length_guess); sv_2mortal(RETVAL); /* so we can use croak w/o memory leaks */ SvPOK_only(RETVAL); re_s = re_p = SvPV_nolen(RETVAL); re_e = re_s + SvLEN(RETVAL); skip_p = NULL; for(in_p = in_s; in_p < in_e; in_p++) { c = *in_p; /* we don't care whether it's UTF-8 */ if(!isBASE(c)) croak("non-base character in input for decode_punycode"); if(c == DELIM) skip_p = in_p; *re_p++ = c; /* copy it */ } if(skip_p) { h = skip_p - in_s; /* base chars handled */ re_p = re_s + h; /* points to end of base chars */ skip_p++; /* skip over DELIM */ } else { h = 0; /* no base chars */ re_p = re_s; skip_p = in_s; /* read everything */ } for(in_p = skip_p; in_p < in_e; i++) { oldi = i; w = 1; for(k = BASE;; k+= BASE) { if(!(in_p < in_e)) croak("incomplete encoded code point in decode_punycode"); c = dec_digit[*in_p++]; /* we already know it's in 0..127 */ if(((IV)c) < 0) croak("invalid digit in input for decode_punycode"); i += c * w; t = TMIN_MAX(k - bias); if(c < t) break; w *= BASE-t; } h++; bias = adapt(i-oldi, h, first); first = 0; n += i / h; /* code point n to insert */ i = i % h; /* at position i */ u8 = UNISKIP(n); /* how many bytes we need */ if(re_p + u8 >= re_e) { length_guess = re_e - re_p + u8 + 16; re_e = SvGROW(RETVAL, length_guess); re_p = re_e + (re_p - re_s); re_s = re_e; re_e = re_s + SvLEN(RETVAL); } j = i; for(skip_p = re_s; j > 0; j--) /* find position in UTF-8 */ skip_p+=UTF8SKIP(skip_p); if(skip_p < re_p) /* move succeeding chars */ Move(skip_p, skip_p + u8, re_p - skip_p, char); re_p += u8; uvuni_to_utf8_flags(skip_p, n, UNICODE_ALLOW_ANY); } if(!first) SvUTF8_on(RETVAL); /* UTF-8 chars have been inserted */ *re_p = 0; SvCUR_set(RETVAL, re_p - re_s); ST(0) = RETVAL; XSRETURN(1); Net-IDN-Encode-1.000/lib/Net/IDN/Punycode/000075500000000000000000000000001135223703100175325ustar00rootroot00000000000000Net-IDN-Encode-1.000/lib/Net/IDN/Punycode/PP.pm000064400000000000000000000106511135223703100204120ustar00rootroot00000000000000package Net::IDN::Punycode::PP; use 5.007_001; use strict; use utf8; use warnings; use Carp; use Exporter; our $VERSION = "1.000"; our @ISA = qw(Exporter); our @EXPORT = (); our @EXPORT_OK = qw(encode_punycode decode_punycode); our %EXPORT_TAGS = ( 'all' => \@EXPORT_OK ); use integer; 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 = "\x00-\x7f"; my $PunyRE = "A-Za-z0-9"; 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)); } sub decode_punycode { die("Usage: Net::IDN::Punycode::decode_punycode(input)") unless @_; my $input = shift; my $n = INITIAL_N; my $i = 0; my $bias = INITIAL_BIAS; my @output; return undef unless defined $input; return '' unless length $input; if($input =~ s/(.*)$Delimiter//os) { my $base_chars = $1; croak("non-base character in input for decode_punycode") if $base_chars =~ m/[^$BasicRE]/os; push @output, split //, $base_chars; } my $code = $input; croak('invalid digit in input for decode_punycode') if $code =~ m/[^$PunyRE]/os; utf8::downgrade($input); ## handling failure of downgrade is more expensive than ## doing the above regexp w/ utf8 semantics while(length $code) { my $oldi = $i; my $w = 1; LOOP: for (my $k = BASE; 1; $k += BASE) { my $cp = substr($code, 0, 1, ''); croak("incomplete encoded code point in decode_punycode") if !defined $cp; my $digit = ord $cp; ## NB: this depends on the PunyRE catching invalid digit characters ## before they turn up here ## $digit = $digit < 0x40 ? $digit + (26-0x30) : ($digit & 0x1f) -1; $i += $digit * $w; my $t = $k - $bias; $t = $t < TMIN ? TMIN : $t > TMAX ? TMAX : $t; last LOOP if $digit < $t; $w *= (BASE - $t); } $bias = _adapt($i - $oldi, @output + 1, $oldi == 0); $n += $i / (@output + 1); $i = $i % (@output + 1); splice(@output, $i, 0, chr($n)); $i++; } return join '', @output; } sub encode_punycode { die("Usage: Net::IDN::Punycode::encode_punycode(input)") unless @_; my $input = shift; my $input_length = length $input; ## my $output = join '', $input =~ m/([$BasicRE]+)/og; ## slower my $output = $input; $output =~ s/[^$BasicRE]+//ogs; my $h = my $b = length $output; $output .= $Delimiter if $b > 0; utf8::downgrade($output); ## no unnecessary use of utf8 semantics my @input = map ord, split //, $input; my @chars = sort grep { $_ >= INITIAL_N } @input; my $n = INITIAL_N; my $delta = 0; my $bias = INITIAL_BIAS; foreach my $m (@chars) { next if $m < $n; $delta += ($m - $n) * ($h + 1); $n = $m; for(my $i = 0; $i < $input_length; $i++) { my $c = $input[$i]; $delta++ if $c < $n; if ($c == $n) { my $q = $delta; LOOP: for (my $k = BASE; 1; $k += BASE) { my $t = $k - $bias; $t = $t < TMIN ? TMIN : $t > TMAX ? TMAX : $t; last LOOP if $q < $t; my $o = $t + (($q - $t) % (BASE - $t)); $output .= chr $o + ($o < 26 ? 0x61 : 0x30-26); $q = ($q - $t) / (BASE - $t); } croak("input exceeds punycode limit") if $q > BASE; $output .= chr $q + ($q < 26 ? 0x61 : 0x30-26); $bias = _adapt($delta, $h + 1, $h == $b); $delta = 0; $h++; } } $delta++; $n++; } return $output; } 1; __END__ =head1 NAME Net::IDN::Punycode::PP - pure-perl implementation of Net::IDN::Punycode =head1 DESCRIPTION See L. =head1 AUTHORS Tatsuhiko Miyagawa Emiyagawa@bulknews.netE (versions 0.01 to 0.02) Claus FErber ECFAERBER@cpan.orgE (from version 1.00) =head1 LICENSE Copyright 2002-2004 Tatsuhiko Miyagawa Emiyagawa@bulknews.netE Copyright 2007-2010 Claus FErber ECFAERBER@cpan.orgE This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. =head1 SEE ALSO S (L), L, L =cut Net-IDN-Encode-1.000/t/000075500000000000000000000000001135223703100143015ustar00rootroot00000000000000Net-IDN-Encode-1.000/t/00use.t000064400000000000000000000002661135223703100154260ustar00rootroot00000000000000use strict; use Test::More tests => 4; use Test::NoWarnings; # use_ok 'Net::IDN::Nameprep'; use_ok 'Net::IDN::Punycode'; use_ok 'Net::IDN::Punycode::PP'; use_ok 'Net::IDN::Encode'; Net-IDN-Encode-1.000/t/encode_bytes.t000064400000000000000000000025331135223703100171340ustar00rootroot00000000000000use bytes; use strict; use Test::More tests => 24; use Test::NoWarnings; use Net::IDN::Encode qw(:all); is(to_ascii('mueller'),'mueller'); is(to_ascii('xn--mller-kva'),'xn--mller-kva'); is(to_ascii('müller'),'xn--mller-kva'); is(to_unicode('mueller'),'mueller'); is(to_unicode('xn--mller-kva'),'müller'); is(to_unicode('müller'),'müller'); is(domain_to_ascii('mueller.example.com'),'mueller.example.com'); is(domain_to_ascii('xn--mller-kva.example.com'),'xn--mller-kva.example.com'); is(domain_to_ascii('müller.example.com'),'xn--mller-kva.example.com'); is(domain_to_unicode('mueller.example.com'),'mueller.example.com'); is(domain_to_unicode('xn--mller-kva.example.com'),'müller.example.com'); is(domain_to_unicode('müller.example.com'),'müller.example.com'); is(email_to_ascii('hans@mueller.example.com'),'hans@mueller.example.com'); is(email_to_ascii('hans@xn--mller-kva.example.com'),'hans@xn--mller-kva.example.com'); is(email_to_ascii('hans@müller.example.com'),'hans@xn--mller-kva.example.com'); is(email_to_ascii(''), ''); is(email_to_ascii(undef), undef); is(email_to_ascii('test'), 'test'); is(email_to_unicode('hans@mueller.example.com'),'hans@mueller.example.com'); is(email_to_unicode('hans@xn--mller-kva.example.com'),'hans@müller.example.com'); is(email_to_unicode(''),''); is(email_to_unicode(undef), undef); is(email_to_unicode('test'),'test'); Net-IDN-Encode-1.000/t/encode_utf8.t000064400000000000000000000035661135223703100167030ustar00rootroot00000000000000use utf8; use strict; use Test::More tests => 32; use Test::NoWarnings; use Net::IDN::Encode qw(:all); is(to_ascii('mueller'),'mueller'); is(to_ascii('xn--mller-kva'),'xn--mller-kva'); is(to_ascii('müller'),'xn--mller-kva'); is(to_ascii('中央大学'),'xn--fiq80yua78t'); is(to_unicode('mueller'),'mueller'); is(to_unicode('xn--mller-kva'),'müller'); is(to_unicode('müller'),'müller'); is(to_unicode('xn--fiq80yua78t'),'中央大学'); is(domain_to_ascii('mueller.example.com'),'mueller.example.com'); is(domain_to_ascii('xn--mller-kva.example.com'),'xn--mller-kva.example.com'); is(domain_to_ascii('müller.example.com'),'xn--mller-kva.example.com'); is(domain_to_ascii('中央大学.tw'),'xn--fiq80yua78t.tw'); is(domain_to_unicode('mueller.example.com'),'mueller.example.com'); is(domain_to_unicode('xn--mller-kva.example.com'),'müller.example.com'); is(domain_to_unicode('müller.example.com'),'müller.example.com'); is(domain_to_unicode('xn--fiq80yua78t.tw'),'中央大学.tw'); is(email_to_ascii('hans@mueller.example.com'),'hans@mueller.example.com'); is(email_to_ascii('hans@xn--mller-kva.example.com'),'hans@xn--mller-kva.example.com'); is(email_to_ascii('hans@müller.example.com'),'hans@xn--mller-kva.example.com'); is(email_to_ascii('test@中央大学.tw'),'test@xn--fiq80yua78t.tw'); is(email_to_ascii(''), ''); is(email_to_ascii(undef), undef); is(email_to_ascii('test'), 'test'); is(email_to_unicode('hans@mueller.example.com'),'hans@mueller.example.com'); is(email_to_unicode('hansï¼ mueller.example.com'),'hans@mueller.example.com'); is(email_to_unicode('hans@xn--mller-kva.example.com'),'hans@müller.example.com'); is(email_to_unicode('hansï¼ xn--mller-kva.example.com'),'hans@müller.example.com'); is(email_to_unicode('test@xn--fiq80yua78t.tw'),'test@中央大学.tw'); is(email_to_unicode(''),''); is(email_to_unicode(undef), undef); is(email_to_unicode('test'),'test'); Net-IDN-Encode-1.000/t/punycode_vec-pp.t000064400000000000000000000140231135223703100175660ustar00rootroot00000000000000use strict; use utf8; use Test::More; use Test::NoWarnings; use Net::IDN::Punycode::PP ':all'; our @idna = ( ["Arabic (Egyptian)", "\x{0644}\x{064A}\x{0647}\x{0645}\x{0627}\x{0628}\x{062A}\x{0643}". "\x{0644}\x{0645}\x{0648}\x{0634}\x{0639}\x{0631}\x{0628}\x{064A}\x{061F}", "egbpdaj6bu4bxfgehfvwxn", 0, 0, 1, 1 ], ["Chinese (simplified)", "\x{4ED6}\x{4EEC}\x{4E3A}\x{4EC0}\x{4E48}\x{4E0D}\x{8BF4}\x{4E2D}". "\x{6587}", "ihqwcrb4cv8a8dqg056pqjye", 0, 0, 1, 1 ], ["Chinese (traditional)", "\x{4ED6}\x{5011}\x{7232}\x{4EC0}\x{9EBD}\x{4E0D}\x{8AAA}\x{4E2D}". "\x{6587}", "ihqwctvzc91f659drss3x8bo0yb", 0, 0, 1, 1 ], ["Czech", "\x{0050}\x{0072}\x{006F}\x{010D}\x{0070}\x{0072}\x{006F}\x{0073}". "\x{0074}\x{011B}\x{006E}\x{0065}\x{006D}\x{006C}\x{0075}\x{0076}\x{00ED}". "\x{010D}\x{0065}\x{0073}\x{006B}\x{0079}", "Proprostnemluvesky-uyb24dma41a", 0, 0, 1, 1 ], ["Hebrew", "\x{05DC}\x{05DE}\x{05D4}\x{05D4}\x{05DD}\x{05E4}\x{05E9}\x{05D5}". "\x{05D8}\x{05DC}\x{05D0}\x{05DE}\x{05D3}\x{05D1}\x{05E8}\x{05D9}\x{05DD}". "\x{05E2}\x{05D1}\x{05E8}\x{05D9}\x{05EA}", "4dbcagdahymbxekheh6e0a7fei0b", 0, 0, 1, 1 ], ["Hindi (Devanagari)", "\x{092F}\x{0939}\x{0932}\x{094B}\x{0917}\x{0939}\x{093F}\x{0928}". "\x{094D}\x{0926}\x{0940}\x{0915}\x{094D}\x{092F}\x{094B}\x{0902}\x{0928}". "\x{0939}\x{0940}\x{0902}\x{092C}\x{094B}\x{0932}\x{0938}\x{0915}\x{0924}". "\x{0947}\x{0939}\x{0948}\x{0902}", "i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd", 0, 0, 1 ], ["Japanese (kanji and hiragana)", "\x{306A}\x{305C}\x{307F}\x{3093}\x{306A}\x{65E5}\x{672C}\x{8A9E}". "\x{3092}\x{8A71}\x{3057}\x{3066}\x{304F}\x{308C}\x{306A}\x{3044}\x{306E}". "\x{304B}", "n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa", 0, 0, 1 ], ["Russian (Cyrillic)", "\x{043F}\x{043E}\x{0447}\x{0435}\x{043C}\x{0443}\x{0436}\x{0435}". "\x{043E}\x{043D}\x{0438}\x{043D}\x{0435}\x{0433}\x{043E}\x{0432}\x{043E}". "\x{0440}\x{044F}\x{0442}\x{043F}\x{043E}\x{0440}\x{0443}\x{0441}\x{0441}". "\x{043A}\x{0438}", "b1abfaaepdrnnbgefbadotcwatmq2g4l", 0, 0, 1, 1 ], ["Spanish", "\x{0050}\x{006F}\x{0072}\x{0071}\x{0075}\x{00E9}\x{006E}\x{006F}". "\x{0070}\x{0075}\x{0065}\x{0064}\x{0065}\x{006E}\x{0073}\x{0069}\x{006D}". "\x{0070}\x{006C}\x{0065}\x{006D}\x{0065}\x{006E}\x{0074}\x{0065}\x{0068}". "\x{0061}\x{0062}\x{006C}\x{0061}\x{0072}\x{0065}\x{006E}\x{0045}\x{0073}". "\x{0070}\x{0061}\x{00F1}\x{006F}\x{006C}", "PorqunopuedensimplementehablarenEspaol-fmd56a", 0, 0, 1 ], ["Vietnamese", "\x{0054}\x{1EA1}\x{0069}\x{0073}\x{0061}\x{006F}\x{0068}\x{1ECD}". "\x{006B}\x{0068}\x{00F4}\x{006E}\x{0067}\x{0074}\x{0068}\x{1EC3}\x{0063}". "\x{0068}\x{1EC9}\x{006E}\x{00F3}\x{0069}\x{0074}\x{0069}\x{1EBF}\x{006E}". "\x{0067}\x{0056}\x{0069}\x{1EC7}\x{0074}", "TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g", 0, 0, 1 ], ["Japanese", "\x{0033}\x{5E74}\x{0042}\x{7D44}\x{91D1}\x{516B}\x{5148}\x{751F}", "3B-ww4c5e180e575a65lsy2b", 0, 0, 1, 1 ], ["Japanese", "\x{5B89}\x{5BA4}\x{5948}\x{7F8E}\x{6075}\x{002D}\x{0077}\x{0069}". "\x{0074}\x{0068}\x{002D}\x{0053}\x{0055}\x{0050}\x{0045}\x{0052}\x{002D}". "\x{004D}\x{004F}\x{004E}\x{004B}\x{0045}\x{0059}\x{0053}", "-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n", 0, 0, 1 ], ["Japanese", "\x{0048}\x{0065}\x{006C}\x{006C}\x{006F}\x{002D}\x{0041}\x{006E}". "\x{006F}\x{0074}\x{0068}\x{0065}\x{0072}\x{002D}\x{0057}\x{0061}\x{0079}". "\x{002D}\x{305D}\x{308C}\x{305E}\x{308C}\x{306E}\x{5834}\x{6240}", "Hello-Another-Way--fc4qua05auwb3674vfr0b", 0, 0, 1 ], ["Japanese", "\x{3072}\x{3068}\x{3064}\x{5C4B}\x{6839}\x{306E}\x{4E0B}\x{0032}", "2-u9tlzr9756bt3uc0v", 0, 0, 1, 1 ], ["Japanese", "\x{004D}\x{0061}\x{006A}\x{0069}\x{3067}\x{004B}\x{006F}\x{0069}". "\x{3059}\x{308B}\x{0035}\x{79D2}\x{524D}", "MajiKoi5-783gue6qz075azm5e", 0, 0, 1, 1 ], ["Japanese", "\x{30D1}\x{30D5}\x{30A3}\x{30FC}\x{0064}\x{0065}\x{30EB}\x{30F3}". "\x{30D0}", "de-jg4avhby1noc0d", 0, 0, 1, 1 ], ["Japanese", "\x{305D}\x{306E}\x{30B9}\x{30D4}\x{30FC}\x{30C9}\x{3067}", "d9juau41awczczp", 0, 0, 1, 1 ], ["Greek", "\x{03b5}\x{03bb}\x{03bb}\x{03b7}\x{03bd}\x{03b9}\x{03ba}\x{03ac}", "hxargifdar", 0, 0, 1, 1 ], ["Maltese (Malti)", "\x{0062}\x{006f}\x{006e}\x{0121}\x{0075}\x{0073}\x{0061}\x{0127}". "\x{0127}\x{0061}", "bonusaa-5bb1da", 0, 0, 1, 1 ], ["Russian (Cyrillic)", "\x{043f}\x{043e}\x{0447}\x{0435}\x{043c}\x{0443}\x{0436}\x{0435}". "\x{043e}\x{043d}\x{0438}\x{043d}\x{0435}\x{0433}\x{043e}\x{0432}\x{043e}". "\x{0440}\x{044f}\x{0442}\x{043f}\x{043e}\x{0440}\x{0443}\x{0441}\x{0441}". "\x{043a}\x{0438}", "b1abfaaepdrnnbgefbadotcwatmq2g4l", 0, 0, 1, 1 ], ); plan tests => ($#idna+1)*2 + 1; foreach my $test (@idna) { my ($comment,$in,$out,$allowunassigned,$usestd3asciirules,$toascii,$tounicode) = @{$test}; is(encode_punycode($in), $out, $comment.' (encode_punycode)'); is(decode_punycode($out), $in, $comment.' (decode_punycode)'); } # Test vectors extracted from: # # Nameprep and IDNA Test Vectors # draft-josefsson-idn-test-vectors # # Copyright (C) The Internet Society (2003). All Rights Reserved. # # This document and translations of it may be copied and furnished # to others, and derivative works that comment on or otherwise # explain it or assist in its implementation may be prepared, # copied, published and distributed, in whole or in part, without # restriction of any kind, provided that the above copyright # notice and this paragraph are included on all such copies and # derivative works. However, this document itself may not be # modified in any way, such as by removing the copyright notice or # references to the Internet Society or other Internet # organizations, except as needed for the purpose of developing # Internet standards in which case the procedures for copyrights # defined in the Internet Standards process must be followed, or # as required to translate it into languages other than English. Net-IDN-Encode-1.000/t/punycode_vec.t000064400000000000000000000140171135223703100171540ustar00rootroot00000000000000use strict; use utf8; use Test::More; use Test::NoWarnings; use Net::IDN::Punycode ':all'; our @idna = ( ["Arabic (Egyptian)", "\x{0644}\x{064A}\x{0647}\x{0645}\x{0627}\x{0628}\x{062A}\x{0643}". "\x{0644}\x{0645}\x{0648}\x{0634}\x{0639}\x{0631}\x{0628}\x{064A}\x{061F}", "egbpdaj6bu4bxfgehfvwxn", 0, 0, 1, 1 ], ["Chinese (simplified)", "\x{4ED6}\x{4EEC}\x{4E3A}\x{4EC0}\x{4E48}\x{4E0D}\x{8BF4}\x{4E2D}". "\x{6587}", "ihqwcrb4cv8a8dqg056pqjye", 0, 0, 1, 1 ], ["Chinese (traditional)", "\x{4ED6}\x{5011}\x{7232}\x{4EC0}\x{9EBD}\x{4E0D}\x{8AAA}\x{4E2D}". "\x{6587}", "ihqwctvzc91f659drss3x8bo0yb", 0, 0, 1, 1 ], ["Czech", "\x{0050}\x{0072}\x{006F}\x{010D}\x{0070}\x{0072}\x{006F}\x{0073}". "\x{0074}\x{011B}\x{006E}\x{0065}\x{006D}\x{006C}\x{0075}\x{0076}\x{00ED}". "\x{010D}\x{0065}\x{0073}\x{006B}\x{0079}", "Proprostnemluvesky-uyb24dma41a", 0, 0, 1, 1 ], ["Hebrew", "\x{05DC}\x{05DE}\x{05D4}\x{05D4}\x{05DD}\x{05E4}\x{05E9}\x{05D5}". "\x{05D8}\x{05DC}\x{05D0}\x{05DE}\x{05D3}\x{05D1}\x{05E8}\x{05D9}\x{05DD}". "\x{05E2}\x{05D1}\x{05E8}\x{05D9}\x{05EA}", "4dbcagdahymbxekheh6e0a7fei0b", 0, 0, 1, 1 ], ["Hindi (Devanagari)", "\x{092F}\x{0939}\x{0932}\x{094B}\x{0917}\x{0939}\x{093F}\x{0928}". "\x{094D}\x{0926}\x{0940}\x{0915}\x{094D}\x{092F}\x{094B}\x{0902}\x{0928}". "\x{0939}\x{0940}\x{0902}\x{092C}\x{094B}\x{0932}\x{0938}\x{0915}\x{0924}". "\x{0947}\x{0939}\x{0948}\x{0902}", "i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd", 0, 0, 1 ], ["Japanese (kanji and hiragana)", "\x{306A}\x{305C}\x{307F}\x{3093}\x{306A}\x{65E5}\x{672C}\x{8A9E}". "\x{3092}\x{8A71}\x{3057}\x{3066}\x{304F}\x{308C}\x{306A}\x{3044}\x{306E}". "\x{304B}", "n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa", 0, 0, 1 ], ["Russian (Cyrillic)", "\x{043F}\x{043E}\x{0447}\x{0435}\x{043C}\x{0443}\x{0436}\x{0435}". "\x{043E}\x{043D}\x{0438}\x{043D}\x{0435}\x{0433}\x{043E}\x{0432}\x{043E}". "\x{0440}\x{044F}\x{0442}\x{043F}\x{043E}\x{0440}\x{0443}\x{0441}\x{0441}". "\x{043A}\x{0438}", "b1abfaaepdrnnbgefbadotcwatmq2g4l", 0, 0, 1, 1 ], ["Spanish", "\x{0050}\x{006F}\x{0072}\x{0071}\x{0075}\x{00E9}\x{006E}\x{006F}". "\x{0070}\x{0075}\x{0065}\x{0064}\x{0065}\x{006E}\x{0073}\x{0069}\x{006D}". "\x{0070}\x{006C}\x{0065}\x{006D}\x{0065}\x{006E}\x{0074}\x{0065}\x{0068}". "\x{0061}\x{0062}\x{006C}\x{0061}\x{0072}\x{0065}\x{006E}\x{0045}\x{0073}". "\x{0070}\x{0061}\x{00F1}\x{006F}\x{006C}", "PorqunopuedensimplementehablarenEspaol-fmd56a", 0, 0, 1 ], ["Vietnamese", "\x{0054}\x{1EA1}\x{0069}\x{0073}\x{0061}\x{006F}\x{0068}\x{1ECD}". "\x{006B}\x{0068}\x{00F4}\x{006E}\x{0067}\x{0074}\x{0068}\x{1EC3}\x{0063}". "\x{0068}\x{1EC9}\x{006E}\x{00F3}\x{0069}\x{0074}\x{0069}\x{1EBF}\x{006E}". "\x{0067}\x{0056}\x{0069}\x{1EC7}\x{0074}", "TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g", 0, 0, 1 ], ["Japanese", "\x{0033}\x{5E74}\x{0042}\x{7D44}\x{91D1}\x{516B}\x{5148}\x{751F}", "3B-ww4c5e180e575a65lsy2b", 0, 0, 1, 1 ], ["Japanese", "\x{5B89}\x{5BA4}\x{5948}\x{7F8E}\x{6075}\x{002D}\x{0077}\x{0069}". "\x{0074}\x{0068}\x{002D}\x{0053}\x{0055}\x{0050}\x{0045}\x{0052}\x{002D}". "\x{004D}\x{004F}\x{004E}\x{004B}\x{0045}\x{0059}\x{0053}", "-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n", 0, 0, 1 ], ["Japanese", "\x{0048}\x{0065}\x{006C}\x{006C}\x{006F}\x{002D}\x{0041}\x{006E}". "\x{006F}\x{0074}\x{0068}\x{0065}\x{0072}\x{002D}\x{0057}\x{0061}\x{0079}". "\x{002D}\x{305D}\x{308C}\x{305E}\x{308C}\x{306E}\x{5834}\x{6240}", "Hello-Another-Way--fc4qua05auwb3674vfr0b", 0, 0, 1 ], ["Japanese", "\x{3072}\x{3068}\x{3064}\x{5C4B}\x{6839}\x{306E}\x{4E0B}\x{0032}", "2-u9tlzr9756bt3uc0v", 0, 0, 1, 1 ], ["Japanese", "\x{004D}\x{0061}\x{006A}\x{0069}\x{3067}\x{004B}\x{006F}\x{0069}". "\x{3059}\x{308B}\x{0035}\x{79D2}\x{524D}", "MajiKoi5-783gue6qz075azm5e", 0, 0, 1, 1 ], ["Japanese", "\x{30D1}\x{30D5}\x{30A3}\x{30FC}\x{0064}\x{0065}\x{30EB}\x{30F3}". "\x{30D0}", "de-jg4avhby1noc0d", 0, 0, 1, 1 ], ["Japanese", "\x{305D}\x{306E}\x{30B9}\x{30D4}\x{30FC}\x{30C9}\x{3067}", "d9juau41awczczp", 0, 0, 1, 1 ], ["Greek", "\x{03b5}\x{03bb}\x{03bb}\x{03b7}\x{03bd}\x{03b9}\x{03ba}\x{03ac}", "hxargifdar", 0, 0, 1, 1 ], ["Maltese (Malti)", "\x{0062}\x{006f}\x{006e}\x{0121}\x{0075}\x{0073}\x{0061}\x{0127}". "\x{0127}\x{0061}", "bonusaa-5bb1da", 0, 0, 1, 1 ], ["Russian (Cyrillic)", "\x{043f}\x{043e}\x{0447}\x{0435}\x{043c}\x{0443}\x{0436}\x{0435}". "\x{043e}\x{043d}\x{0438}\x{043d}\x{0435}\x{0433}\x{043e}\x{0432}\x{043e}". "\x{0440}\x{044f}\x{0442}\x{043f}\x{043e}\x{0440}\x{0443}\x{0441}\x{0441}". "\x{043a}\x{0438}", "b1abfaaepdrnnbgefbadotcwatmq2g4l", 0, 0, 1, 1 ], ); plan tests => ($#idna+1)*2 + 1; foreach my $test (@idna) { my ($comment,$in,$out,$allowunassigned,$usestd3asciirules,$toascii,$tounicode) = @{$test}; is(encode_punycode($in), $out, $comment.' (encode_punycode)'); is(decode_punycode($out), $in, $comment.' (decode_punycode)'); } # Test vectors extracted from: # # Nameprep and IDNA Test Vectors # draft-josefsson-idn-test-vectors # # Copyright (C) The Internet Society (2003). All Rights Reserved. # # This document and translations of it may be copied and furnished # to others, and derivative works that comment on or otherwise # explain it or assist in its implementation may be prepared, # copied, published and distributed, in whole or in part, without # restriction of any kind, provided that the above copyright # notice and this paragraph are included on all such copies and # derivative works. However, this document itself may not be # modified in any way, such as by removing the copyright notice or # references to the Internet Society or other Internet # organizations, except as needed for the purpose of developing # Internet standards in which case the procedures for copyrights # defined in the Internet Standards process must be followed, or # as required to translate it into languages other than English.