From erikabele at rubyforge.org Mon Sep 12 22:32:29 2005
From: erikabele at rubyforge.org (erikabele@rubyforge.org)
Date: Mon Sep 12 22:32:30 2005
Subject: site robots.txt
Message-ID: <200509130232.j8D2WTcR003860@rubyforge.org>
Update of /var/cvs/idn/site
In directory rubyforge.org:/tmp/cvs-serv3796
Added Files:
robots.txt
Log Message:
Added robots.txt file.
--- NEW FILE: robots.txt ---
User-agent: *
Disallow: /softwaremap/ # This is an infinite virtual URL space
Disallow: /statcvs/ # This is an infinite virtual URL space
Disallow: /usage/ # This is an infinite virtual URL space
Disallow: /wiki/ # This is an infinite virtual URL space
From erikabele at rubyforge.org Sun Sep 25 19:31:07 2005
From: erikabele at rubyforge.org (erikabele@rubyforge.org)
Date: Sun, 25 Sep 2005 23:31:07 +0000
Subject: site index.html robots.txt
Message-ID: <200509252331.j8PNV705029546@rubyforge.org>
Update of /var/cvs/idn/site
In directory rubyforge.org:/tmp/cvs-serv29537
Modified Files:
index.html robots.txt
Log Message:
Update website in preparation of upcoming release.
Index: index.html
===================================================================
RCS file: /var/cvs/idn/site/index.html,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** index.html 13 Sep 2005 02:25:55 -0000 1.1.1.1
--- index.html 25 Sep 2005 23:31:04 -0000 1.2
***************
*** 20,26 ****
project page.
! Documentation
--- 20,27 ----
project page.
! Resources
Index: robots.txt
===================================================================
RCS file: /var/cvs/idn/site/robots.txt,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** robots.txt 13 Sep 2005 02:32:27 -0000 1.1
--- robots.txt 25 Sep 2005 23:31:04 -0000 1.2
***************
*** 1,5 ****
User-agent: *
! Disallow: /softwaremap/ # This is an infinite virtual URL space
! Disallow: /statcvs/ # This is an infinite virtual URL space
! Disallow: /usage/ # This is an infinite virtual URL space
! Disallow: /wiki/ # This is an infinite virtual URL space
--- 1,4 ----
User-agent: *
! Disallow: /statcvs/
! Disallow: /usage/
! Disallow: /wiki/
From erikabele at rubyforge.org Sun Sep 25 20:22:15 2005
From: erikabele at rubyforge.org (erikabele@rubyforge.org)
Date: Mon, 26 Sep 2005 00:22:15 +0000
Subject: src/ext - New directory
Message-ID: <200509260022.j8Q0MF05002521@rubyforge.org>
Update of /var/cvs/idn/src/ext
In directory rubyforge.org:/tmp/cvs-serv2510/ext
Log Message:
Directory /var/cvs/idn/src/ext added to the repository
From erikabele at rubyforge.org Sun Sep 25 20:22:15 2005
From: erikabele at rubyforge.org (erikabele@rubyforge.org)
Date: Mon, 26 Sep 2005 00:22:15 +0000
Subject: src/lib - New directory
Message-ID: <200509260022.j8Q0MF05002524@rubyforge.org>
Update of /var/cvs/idn/src/lib
In directory rubyforge.org:/tmp/cvs-serv2510/lib
Log Message:
Directory /var/cvs/idn/src/lib added to the repository
From erikabele at rubyforge.org Sun Sep 25 20:22:15 2005
From: erikabele at rubyforge.org (erikabele@rubyforge.org)
Date: Mon, 26 Sep 2005 00:22:15 +0000
Subject: src/test - New directory
Message-ID: <200509260022.j8Q0MF05002526@rubyforge.org>
Update of /var/cvs/idn/src/test
In directory rubyforge.org:/tmp/cvs-serv2510/test
Log Message:
Directory /var/cvs/idn/src/test added to the repository
From erikabele at rubyforge.org Sun Sep 25 20:23:47 2005
From: erikabele at rubyforge.org (erikabele@rubyforge.org)
Date: Mon, 26 Sep 2005 00:23:47 +0000
Subject: src CHANGES LICENSE NOTICE README Rakefile
Message-ID: <200509260023.j8Q0Nl05002620@rubyforge.org>
Update of /var/cvs/idn/src
In directory rubyforge.org:/tmp/cvs-serv2607
Added Files:
CHANGES LICENSE NOTICE README Rakefile
Log Message:
Initial import of src module.
--- NEW FILE: README ---
== LibIDN Ruby Bindings
Version 0.0.1
Ruby Bindings for the GNU LibIDN library, an implementation of the
Stringprep, Punycode and IDNA specifications defined by the IETF
Internationalized Domain Names (IDN) working group.
Included are the most important parts of the Stringprep, Punycode
and IDNA APIs like performing Stringprep processings, encoding to
and decoding from Punycode strings and converting entire domain names
to and from the ACE encoded form.
The latest version of the LibIDN Ruby Bindings project and its
documentation can always be found at
* http://rubyforge.org/projects/idn
See the CHANGES file for detailed information on the changes of every
released version.
=== Requirements
* GNU LibIDN[http://www.gnu.org/software/libidn/] Library
* Rake[http://rubyforge.org/projects/rake] to run the tests and generate
the documentation
* RubyGems[http://docs.rubygems.org/] to produce a Gem package
=== Installation
You can easily install the LibIDN Ruby Bindings by following one of the
ways outlined below:
==== Automatic installation and management with RubyGems
Simply invoke the standard RubyGems commands (install, update, ...),
for example:
% gem install --remote --test idn
or if the GNU LibIDN library can only be found in a non-standard location
% gem install --remote --test idn -- \
--with-idn-dir=/path/to/non/standard/location
or in an even more complex setup
% gem install --remote --test idn -- \
--with-idn-lib=/path/to/non/standard/location/lib \
--with-idn-include=/path/to/non/standard/location/include
==== Semi-automatic installation with Rake
If you are not able to or don't want to use RubyGems you can simply
download the latest release and install it with the help of Rake:
% tar -xvzf idn-x.x.x.tar.gz
% cd idn-x.x.x
% rake install
or if the GNU LibIDN library can only be found in a non-standard location
% rake install IDN_DIR=/path/to/non/standard/location
You can also run the tests or generate the documentation; just call Rake
with the '--tasks' parameter to get an overview of the available tasks:
% rake --tasks
==== Manual installation with extconf.rb
If you are not able to or don't want to use even Rake then you will have to
do a little bit more work by yourself:
% tar -xvzf idn-x.x.x.tar.gz
% cd idn-x.x.x/ext
% ruby extconf.rb
or if the GNU LibIDN library can only be found in a non-standard location
% ruby extconf.rb \
--with-idn-dir=/path/to/non/standard/location
or in an even more complex setup
% ruby extconf.rb \
--with-idn-lib=/path/to/non/standard/location/lib \
--with-idn-include=/path/to/non/standard/location/include
and finally
% make
% sudo make install
=== Documentation
The complete documentation is available online at
* http://idn.rubyforge.org/docs
See also the section on 'Semi-automatic installation with Rake' above for
some details on how to generate the documentation by yourself.
==== Example usage
require 'idn'
include IDN
puts 'Idna.toUnicode: ' + Idna.toUnicode('xn--rksmrgs-5wao1o.josefsson.org')
puts 'Punycode.decode: ' + Punycode.decode('egbpdaj6bu4bxfgehfvwxn')
puts 'Stringprep.with_profile: ' + Stringprep.with_profile('FOO', 'Nameprep')
=== References
[GNU LibIDN]
An implementation of the Stringprep, Punycode and IDNA specifications
defined by the IETF Internationalized Domain Names (IDN) working group,
used for internationalized domain names. The package is available under
the GNU Lesser General Public License.
* http://www.gnu.org/software/libidn
[RFC3454]
P. Hoffman, M. Blanchet, "Preparation of Internationalized Strings
('stringprep')", IETF RFC3454, December 2002.
* http://www.ietf.org/rfc/rfc3454.txt
[RFC3490]
P. Faltstrom, P. Hoffman, A. Costello, "Internationalizing Domain
Names in Applications (IDNA)", IETF RFC3490, March 2003.
* http://www.ietf.org/rfc/rfc3490.txt
[RFC3491]
P. Hoffman, M. Blanchet, "Nameprep: A Stringprep Profile for
Internationalized Domain Names (IDN)", IETF RFC3491, March 2003.
* http://www.ietf.org/rfc/rfc3491.txt
[RFC3492]
A. Costello, "Punycode: A Bootstring encoding of Unicode for
Internationalized Domain Names in Applications (IDNA)", IETF
RFC3492, March 2003.
* http://www.ietf.org/rfc/rfc3492.txt
=== Questions, comments, patches?
If you have any questions, comments or feature requests or if you want
to submit a bug report or provide a patch, then have a look at the project
website at
* http://rubyforge.org/projects/idn
For other information, feel free to ask on the idn-discuss at rubyforge.org
mailing list.
=== Copyright & License
Copyright (c) 2005 Erik Abele. All rights reserved.
This documentation and the software itself are licensed under the Apache
License, Version 2.0 (the "License").
Some portions of the software come with separate copyright notices and are
subject to additional license terms. Please see the file called LICENSE for
further details on these subcomponents of the software.
You may also obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
This software is OSI Certified Open Source Software.
OSI Certified is a certification mark of the Open Source Initiative.
--- NEW FILE: Rakefile ---
# Rakefile for LibIDN Ruby Bindings.
#
# Copyright (c) 2005 Erik Abele. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# Please see the file called LICENSE for further details.
#
# You may also obtain a copy of the License at
#
# * http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This software is OSI Certified Open Source Software.
# OSI Certified is a certification mark of the Open Source Initiative.
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'rake/contrib/sshpublisher'
begin
require 'rubygems'
require 'rake/gempackagetask'
rescue Exception
nil
end
PKG_NAME = 'idn'
PKG_VERSION = '0.0.1'
PKG_AUTHOR = 'Erik Abele'
PKG_EMAIL = 'erikabele at rubyforge.org'
PKG_SUMMARY = 'LibIDN Ruby Bindings'
PKG_DESCRIPTION = <<-EOF
Ruby Bindings for the GNU LibIDN library, an implementation of the
Stringprep, Punycode and IDNA specifications defined by the IETF
Internationalized Domain Names (IDN) working group.
Included are the most important parts of the Stringprep, Punycode
and IDNA APIs like performing Stringprep processings, encoding to
and decoding from Punycode strings and converting entire domain names
to and from the ACE encoded form.
EOF
PKG_FILE_NAME = "#{PKG_NAME}-#{PKG_VERSION}"
PKG_FILES = FileList[
'README', 'CHANGES', 'LICENSE', 'NOTICE', 'Rakefile',
'ext/**/*.{c,h,rb}', 'lib/**/*.rb', 'test/**/*.rb'
]
TEST_FILES = FileList[
'test/ts_*.rb'
]
DOC_FILES = FileList[
'README', 'CHANGES', 'LICENSE', 'lib/**/*.rb',
'ext/idna.c', 'ext/punycode.c', 'ext/stringprep.c', 'ext/idn.c'
]
INFO_NOTE = < [:ext] do
cd 'ext' do
unless system('make install')
STDERR.puts 'ERROR: could not install extension!'
break
end
end
end
desc 'Remove extension products'
task :clobber_ext do
FileList['ext/**/*'].each do |file|
unless FileList['ext/**/*.{c,h,rb}'].include?(file)
rm_r file if File.exists?(file)
end
end
end
desc 'Force a rebuild of the extension files'
task :reext => [:clobber_ext, :ext]
desc 'Remove all files created during the build process'
task :clobber => [:clobber_doc, :clobber_ext, :clobber_package]
Rake::TestTask.new do |test|
test.test_files = TEST_FILES
test.verbose = true
test.warning = true
end
Rake::RDocTask.new('doc') do |rdoc|
rdoc.rdoc_files = DOC_FILES
rdoc.rdoc_dir = 'doc'
rdoc.main = 'README'
rdoc.title = "#{PKG_SUMMARY} Documentation"
rdoc.options << '-N' << '-S' << '-w 2'
end
desc 'Publish the documentation'
task :publish_doc => [:redoc] do
Rake::SshDirPublisher.new(PKG_EMAIL,
"/var/www/gforge-projects/#{PKG_NAME}/docs", 'doc').upload
end
if defined?(Gem)
spec = Gem::Specification.new do |s|
s.name = PKG_NAME
s.version = PKG_VERSION
s.author = PKG_AUTHOR
s.email = PKG_EMAIL
s.summary = PKG_SUMMARY
s.description = PKG_DESCRIPTION
s.rubyforge_project = s.name
s.homepage = "http://rubyforge.org/projects/#{PKG_NAME}/"
s.files = PKG_FILES.delete_if {|f| f.include?('CVS')}
s.extensions = ['ext/extconf.rb']
s.require_path = 'lib'
s.autorequire = s.name
s.test_files = TEST_FILES
s.has_rdoc = true
s.extra_rdoc_files = DOC_FILES
s.rdoc_options << '-m' << 'README' <<
'-t' << "#{PKG_SUMMARY} Documentation" <<
'-N' << '-S' << '-w 2'
end
Rake::GemPackageTask.new(spec) do |pkg|
pkg.need_zip = true
pkg.need_tar_gz = true
end
end
--- NEW FILE: NOTICE ---
This product includes software developed by Erik Abele
(http://www.codefaktor.de/).
This software contains code derived from the Net::XMPP for Ruby
project by Yuki Mitsui (http://netxmpp-ruby.jabberstudio.org/).
--- NEW FILE: CHANGES ---
Changes with IDN 0.0.1 (2005-09-26)
* First release.
--- NEW FILE: LICENSE ---
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-- + -- + -- + -- + -- + -- + -- + -- + -- + -- + -- + -- + -- + -- + --
SUBCOMPONENT LICENSES
This software includes a number of subcomponents with separate copyright
notices and additional license terms. Your use of the source code for
these components is subject to the terms and conditions of the following
licenses:
-- + -- + -- + -- + -- + -- + -- + -- + -- + -- + -- + -- + -- + -- + --
= ext/idn.c
= ext/idn.h
= ext/punycode.c
= ext/stringprep.c
Portions Copyright (c) 2005 Yuki Mitsui. All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in
the documentation and/or other materials provided with the
distribution.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-- + -- + -- + -- + -- + -- + -- + -- + -- + -- + -- + -- + -- + -- + --
+ END OF ALL TERMS AND CONDITIONS +
From erikabele at rubyforge.org Sun Sep 25 20:23:47 2005
From: erikabele at rubyforge.org (erikabele@rubyforge.org)
Date: Mon, 26 Sep 2005 00:23:47 +0000
Subject: src/ext extconf.rb idn.c idn.h idna.c punycode.c stringprep.c
Message-ID: <200509260023.j8Q0Nl05002621@rubyforge.org>
Update of /var/cvs/idn/src/ext
In directory rubyforge.org:/tmp/cvs-serv2607/ext
Added Files:
extconf.rb idn.c idn.h idna.c punycode.c stringprep.c
Log Message:
Initial import of src module.
--- NEW FILE: idn.c ---
/*
* Copyright (c) 2005 Erik Abele. All rights reserved.
* Portions Copyright (c) 2005 Yuki Mitsui. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Please see the file called LICENSE for further details.
*
* You may also obtain a copy of the License at
*
* * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This software is OSI Certified Open Source Software.
* OSI Certified is a certification mark of the Open Source Initiative.
*/
#include
#include "idn.h"
/*
* Document-class: IDN
* The main module of LibIDN Ruby Bindings.
*
* === Example usage
*
* require 'idn'
* include IDN
*
* ...
*/
VALUE mIDN;
/*
* Document-class: IDN::IDNError
* The superclass for all exceptions raised by the IDN extension.
*/
VALUE eIDNError;
/*
* Module Initialization.
*/
void Init_idn(void)
{
mIDN = rb_define_module("IDN");
eIDNError = rb_define_class_under(mIDN, "IDNError", rb_eStandardError);
init_idna();
init_punycode();
init_stringprep();
}
--- NEW FILE: idna.c ---
/*
* Copyright (c) 2005 Erik Abele. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Please see the file called LICENSE for further details.
*
* You may also obtain a copy of the License at
*
* * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This software is OSI Certified Open Source Software.
* OSI Certified is a certification mark of the Open Source Initiative.
*/
#include
#include
#include
#include "idn.h"
/*
* Document-class: IDN::Idna
* The Idna module of LibIDN Ruby Bindings.
*
* === Example usage
*
* require 'idn'
* include IDN
*
* puts 'ACE-Prefix: ' + Idna::ACE_PREFIX
*
* domain = Idna.toUnicode('xn--rksmrgs-5wao1o.josefsson.org',
* Idna::USE_STD3_ASCII_RULES | Idna::ALLOW_UNASSIGNED)
*
* === Constants
*
* ACE_PREFIX
* - The ACE prefix: 'xn--'.
*
* ALLOW_UNASSIGNED
* - Used as flag for toASCII/toUnicode.
*
* USE_STD3_ASCII_RULES
* - Used as flag for toASCII/toUnicode.
*/
VALUE mIdna;
/*
* Document-class: IDN::Idna::IdnaError
* The base class for all exceptions raised by the IDN::Idna module.
*/
VALUE eIdnaError;
/*
* call-seq:
* IDN::Idna.toASCII(string, flags=nil) => string
*
* Converts a domain name in UTF-8 format into an ASCII string. The domain
* name may contain several labels, separated by dots.
*
* Raises IDN::Idna::IdnaError on failure.
*/
static VALUE toASCII(int argc, VALUE argv[], VALUE self)
{
int rc;
char *buf;
VALUE str, flags, retv;
rb_scan_args(argc, argv, "11", &str, &flags);
str = rb_check_convert_type(str, T_STRING, "String", "to_s");
if (flags != Qnil) {
Check_Type(flags, T_FIXNUM);
flags = FIX2INT(flags);
} else {
flags = 0x0000;
}
rc = idna_to_ascii_8z(RSTRING(str)->ptr, &buf, flags);
if (rc != IDNA_SUCCESS) {
xfree(buf);
rb_raise(eIdnaError, "%s (%d)", idna_strerror(rc), rc);
return Qnil;
}
retv = rb_str_new2(buf);
xfree(buf);
return retv;
}
/*
* call-seq:
* IDN::Idna.toUnicode(string, flags=nil) => string
*
* Converts a possibly ACE encoded domain name in UTF-8 format into an
* UTF-8 string. The domain name may contain several labels, separated
* by dots.
*
* Raises IDN::Idna::IdnaError on failure.
*/
static VALUE toUnicode(int argc, VALUE argv[], VALUE self)
{
int rc;
char *buf;
VALUE str, flags, retv;
rb_scan_args(argc, argv, "11", &str, &flags);
str = rb_check_convert_type(str, T_STRING, "String", "to_s");
if (flags != Qnil) {
Check_Type(flags, T_FIXNUM);
flags = FIX2INT(flags);
} else {
flags = 0x0000;
}
rc = idna_to_unicode_8z8z(RSTRING(str)->ptr, &buf, flags);
if (rc != IDNA_SUCCESS) {
xfree(buf);
rb_raise(eIdnaError, "%s (%d)", idna_strerror(rc), rc);
return Qnil;
}
retv = rb_str_new2(buf);
xfree(buf);
return retv;
}
/*
* Module Initialization.
*/
void init_idna(void)
{
#ifdef mIDN_RDOC_HACK
mIDN = rb_define_module("IDN");
eIDNError = rb_define_class_under(mIDN, "IDNError", rb_eStandardError);
#endif
mIdna = rb_define_module_under(mIDN, "Idna");
eIdnaError = rb_define_class_under(mIdna, "IdnaError", eIDNError);
rb_define_const(mIdna, "ACE_PREFIX",
rb_str_new2(IDNA_ACE_PREFIX));
rb_define_const(mIdna, "ALLOW_UNASSIGNED",
INT2FIX(IDNA_ALLOW_UNASSIGNED));
rb_define_const(mIdna, "USE_STD3_ASCII_RULES",
INT2FIX(IDNA_USE_STD3_ASCII_RULES));
rb_define_singleton_method(mIdna, "toASCII", toASCII, -1);
rb_define_singleton_method(mIdna, "toUnicode", toUnicode, -1);
}
--- NEW FILE: idn.h ---
/*
* Copyright (c) 2005 Erik Abele. All rights reserved.
* Portions Copyright (c) 2005 Yuki Mitsui. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Please see the file called LICENSE for further details.
*
* You may also obtain a copy of the License at
*
* * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This software is OSI Certified Open Source Software.
* OSI Certified is a certification mark of the Open Source Initiative.
*/
#ifndef ___IDN_IDN_H_
#define ___IDN_IDN_H_
#include
/*
* idn.c
*/
extern VALUE mIDN;
extern VALUE eIDNError;
/*
* idna.c
*/
extern VALUE mIdna;
extern VALUE eIdnaError;
void init_idna(void);
/*
* punycode.c
*/
extern VALUE mPunycode;
extern VALUE ePunycodeError;
void init_punycode(void);
/*
* stringprep.c
*/
extern VALUE mStringprep;
extern VALUE eStringprepError;
void init_stringprep(void);
#endif /* ___IDN_IDN_H_ */
--- NEW FILE: extconf.rb ---
# Makefile configuration for LibIDN Ruby Bindings.
#
# Copyright (c) 2005 Erik Abele. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# Please see the file called LICENSE for further details.
#
# You may also obtain a copy of the License at
#
# * http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This software is OSI Certified Open Source Software.
# OSI Certified is a certification mark of the Open Source Initiative.
require 'mkmf'
@libs = ['idn']
@headers = ['idna.h', 'punycode.h', 'stringprep.h']
INFO_NOTE = <
#include
#include
#include
#include "idn.h"
/*
* Document-class: IDN::Punycode
* The Punycode module of LibIDN Ruby Bindings.
*
* === Example usage
*
* require 'idn'
* include IDN
*
* str = Punycode.decode('egbpdaj6bu4bxfgehfvwxn')
*/
VALUE mPunycode;
/*
* Document-class: IDN::Punycode::PunycodeError
* The base class for all exceptions raised by the IDN::Punycode module.
*/
VALUE ePunycodeError;
/*
* call-seq:
* IDN::Punycode.encode(string) => string
*
* Converts a string in UTF-8 format to Punycode.
*
* Raises IDN::Punycode::PunycodeError on failure.
*/
static VALUE encode(VALUE self, VALUE str)
{
int rc;
punycode_uint *ustr;
size_t len;
size_t buflen = 0x100;
char *buf = NULL;
VALUE retv;
str = rb_check_convert_type(str, T_STRING, "String", "to_s");
ustr = stringprep_utf8_to_ucs4(RSTRING(str)->ptr, RSTRING(str)->len, &len);
while (1) {
buf = realloc(buf, buflen);
if (buf == NULL) {
xfree(ustr);
rb_raise(rb_eNoMemError, "cannot allocate memory (%d bytes)", buflen);
return Qnil;
}
rc = punycode_encode(len, ustr, NULL, &buflen, buf);
if (rc == PUNYCODE_SUCCESS) {
break;
} else if (rc == PUNYCODE_BIG_OUTPUT) {
buflen += 0x100;
} else {
xfree(ustr);
xfree(buf);
rb_raise(ePunycodeError, "%s (%d)", punycode_strerror(rc), rc);
return Qnil;
}
}
retv = rb_str_new(buf, buflen);
xfree(ustr);
xfree(buf);
return retv;
}
/*
* call-seq:
* IDN::Punycode.decode(string) => string
*
* Converts Punycode to a string in UTF-8 format.
*
* Raises IDN::Punycode::PunycodeError on failure.
*/
static VALUE decode(VALUE self, VALUE str)
{
int rc;
punycode_uint *ustr;
size_t len;
char *buf = NULL;
VALUE retv;
str = rb_check_convert_type(str, T_STRING, "String", "to_s");
len = RSTRING(str)->len;
ustr = malloc(len * sizeof(punycode_uint));
if (ustr == NULL) {
rb_raise(rb_eNoMemError, "cannot allocate memory (%d bytes)", len);
return Qnil;
}
rc = punycode_decode(RSTRING(str)->len, RSTRING(str)->ptr,
&len, ustr, NULL);
if (rc != PUNYCODE_SUCCESS) {
xfree(ustr);
rb_raise(ePunycodeError, "%s (%d)", punycode_strerror(rc), rc);
return Qnil;
}
buf = stringprep_ucs4_to_utf8(ustr, len, NULL, &len);
retv = rb_str_new(buf, len);
xfree(ustr);
xfree(buf);
return retv;
}
/*
* Module Initialization.
*/
void init_punycode(void)
{
#ifdef mIDN_RDOC_HACK
mIDN = rb_define_module("IDN");
eIDNError = rb_define_class_under(mIDN, "IDNError", rb_eStandardError);
#endif
mPunycode = rb_define_module_under(mIDN, "Punycode");
ePunycodeError = rb_define_class_under(mPunycode, "PunycodeError",
eIDNError);
rb_define_singleton_method(mPunycode, "encode", encode, 1);
rb_define_singleton_method(mPunycode, "decode", decode, 1);
}
--- NEW FILE: stringprep.c ---
/*
* Copyright (c) 2005 Erik Abele. All rights reserved.
* Portions Copyright (c) 2005 Yuki Mitsui. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* Please see the file called LICENSE for further details.
*
* You may also obtain a copy of the License at
*
* * http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* This software is OSI Certified Open Source Software.
* OSI Certified is a certification mark of the Open Source Initiative.
*/
#include
#include
#include
#include "idn.h"
/*
* Document-class: IDN::Stringprep
* The Stringprep module of LibIDN Ruby Bindings.
*
* === Example usage
*
* require 'idn'
* include IDN
*
* str = Stringprep.with_profile('FOO', 'Nameprep')
*/
VALUE mStringprep;
/*
* Document-class: IDN::Stringprep::StringprepError
* The base class for all exceptions raised by the IDN::Stringprep module.
*/
VALUE eStringprepError;
/*
* Internal helper function:
* stringprep_internal
*
* Prepares the given string in UTF-8 format according to the given
* stringprep profile name. See the various public wrapper functions
* below for details.
*
* Raises IDN::Stringprep::StringprepError on failure.
*/
static VALUE stringprep_internal(VALUE str, const char *profile)
{
int rc;
char *buf;
VALUE retv;
str = rb_check_convert_type(str, T_STRING, "String", "to_s");
rc = stringprep_profile(RSTRING(str)->ptr, &buf, profile, 0);
if (rc != STRINGPREP_OK) {
xfree(buf);
rb_raise(eStringprepError, "%s (%d)", stringprep_strerror(rc), rc);
return Qnil;
}
retv = rb_str_new2(buf);
xfree(buf);
return retv;
}
/*
* call-seq:
* IDN::Stringprep.nameprep(string) => string
*
* Prepares a string in UTF-8 format according to the 'Nameprep'
* profile.
*
* Raises IDN::Stringprep::StringprepError on failure.
*/
static VALUE nameprep(VALUE self, VALUE str)
{
return stringprep_internal(str, "Nameprep");
}
/*
* call-seq:
* IDN::Stringprep.nodeprep(string) => string
*
* Prepares a string in UTF-8 format according to the 'Nodeprep'
* profile.
*
* Raises IDN::Stringprep::StringprepError on failure.
*/
static VALUE nodeprep(VALUE self, VALUE str)
{
return stringprep_internal(str, "Nodeprep");
}
/*
* call-seq:
* IDN::Stringprep.resourceprep(string) => string
*
* Prepares a string in UTF-8 format according to the 'Resourceprep'
* profile.
*
* Raises IDN::Stringprep::StringprepError on failure.
*/
static VALUE resourceprep(VALUE self, VALUE str)
{
return stringprep_internal(str, "Resourceprep");
}
/*
* call-seq:
* IDN::Stringprep.with_profile(string, profile) => string
*
* Prepares a string in UTF-8 format according to the given stringprep
* profile name which must be one of the internally supported stringprep
* profiles (for details see IANA's Profile Names in RFC3454).
*
* Raises IDN::Stringprep::StringprepError on failure.
*/
static VALUE with_profile(VALUE self, VALUE str, VALUE profile)
{
profile = rb_check_convert_type(profile, T_STRING, "String", "to_s");
return stringprep_internal(str, RSTRING(profile)->ptr);
}
/*
* call-seq:
* IDN::Stringprep.nfkc_normalize(string) => string
*
* Converts a string in UTF-8 format into canonical form, standardizing
* such issues as whether a character with an accent is represented as a
* base character and combining accent or as a single precomposed character.
*/
static VALUE nfkc_normalize(VALUE self, VALUE str)
{
char *buf;
VALUE retv;
str = rb_check_convert_type(str, T_STRING, "String", "to_s");
buf = stringprep_utf8_nfkc_normalize(RSTRING(str)->ptr, RSTRING(str)->len);
retv = rb_str_new2(buf);
xfree(buf);
return retv;
}
/*
* Module Initialization.
*/
void init_stringprep(void)
{
#ifdef mIDN_RDOC_HACK
mIDN = rb_define_module("IDN");
eIDNError = rb_define_class_under(mIDN, "IDNError", rb_eStandardError);
#endif
mStringprep = rb_define_module_under(mIDN, "Stringprep");
eStringprepError = rb_define_class_under(mStringprep, "StringprepError",
eIDNError);
rb_define_singleton_method(mStringprep, "nameprep", nameprep, 1);
rb_define_singleton_method(mStringprep, "nodeprep", nodeprep, 1);
rb_define_singleton_method(mStringprep, "resourceprep", resourceprep, 1);
rb_define_singleton_method(mStringprep, "with_profile", with_profile, 2);
rb_define_singleton_method(mStringprep, "nfkc_normalize", nfkc_normalize, 1);
}
From erikabele at rubyforge.org Sun Sep 25 20:23:47 2005
From: erikabele at rubyforge.org (erikabele@rubyforge.org)
Date: Mon, 26 Sep 2005 00:23:47 +0000
Subject: src/test tc_Idna.rb tc_Punycode.rb tc_Stringprep.rb ts_IDN.rb
Message-ID: <200509260023.j8Q0Nl05002623@rubyforge.org>
Update of /var/cvs/idn/src/test
In directory rubyforge.org:/tmp/cvs-serv2607/test
Added Files:
tc_Idna.rb tc_Punycode.rb tc_Stringprep.rb ts_IDN.rb
Log Message:
Initial import of src module.
--- NEW FILE: ts_IDN.rb ---
# Test suite for LibIDN Ruby Bindings.
#
# Copyright (c) 2005 Erik Abele. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# Please see the file called LICENSE for further details.
#
# You may also obtain a copy of the License at
#
# * http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This software is OSI Certified Open Source Software.
# OSI Certified is a certification mark of the Open Source Initiative.
require 'test/unit'
# Construct absolute project path.
project_path = File.join(File.dirname(__FILE__), '..')
# Add project directories to global LOAD_PATH ($:).
$:.unshift File.join(project_path, 'ext'), File.join(project_path, 'lib')
# Require all testcase files.
Dir[File.join(project_path, 'test', 'tc_*.rb')].each { |tc| require tc }
--- NEW FILE: tc_Stringprep.rb ---
# Unit tests for IDN::Stringprep.
#
# Copyright (c) 2005 Erik Abele. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# Please see the file called LICENSE for further details.
#
# You may also obtain a copy of the License at
#
# * http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This software is OSI Certified Open Source Software.
# OSI Certified is a certification mark of the Open Source Initiative.
require 'test/unit'
require 'idn'
class Test_Stringprep < Test::Unit::TestCase
include IDN
# STRINGPREP test vectors: UTF-8 encoded strings and the corresponding
# prepared form, according to the given profile.
TESTCASES_STRINGPREP = {
'A' => [ "Nameprep", "\xC5\x83\xCD\xBA", "\xC5\x84 \xCE\xB9" ],
'B' => [ "Nodeprep", "\xE1\xBE\xB7", "\xE1\xBE\xB6\xCE\xB9" ],
'C' => [ "Resourceprep", "foo at bar", "foo at bar" ],
'D' => [ "ISCSIprep", "Example-Name", "example-name" ],
'E' => [ "SASLprep", "Example\xC2\xA0Name", "Example Name" ]
}
# NFKC test vectors: UTF-8 encoded strings and the corresponding
# normalized form, according to NFKC normalization mode.
TESTCASES_NFKC = {
'A' => [ "\xC2\xB5", "\xCE\xBC" ],
'B' => [ "\xC2\xAA", "\x61" ]
}
def setup
end
def teardown
end
def test_with_profile
TESTCASES_STRINGPREP.each do |key, val|
rc = Stringprep.with_profile(val[1], val[0])
assert_equal(val[2], rc, "TestCase #{key} failed")
end
end
def test_nfkc_normalize
TESTCASES_NFKC.each do |key, val|
rc = Stringprep.nfkc_normalize(val[0])
assert_equal(val[1], rc, "TestCase #{key} failed")
end
end
end
--- NEW FILE: tc_Punycode.rb ---
# Unit tests for IDN::Punycode.
#
# Copyright (c) 2005 Erik Abele. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# Please see the file called LICENSE for further details.
#
# You may also obtain a copy of the License at
#
# * http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This software is OSI Certified Open Source Software.
# OSI Certified is a certification mark of the Open Source Initiative.
require 'test/unit'
require 'idn'
class Test_Punycode < Test::Unit::TestCase
include IDN
# RFC3492 test vectors, taken from RFC3492 (7.1 Sample Strings):
# http://www.ietf.org/rfc/rfc3492.txt
#
# Modifications:
# - correction of an obviously wrong uppercase character in case I
TESTCASES_RFC3492 = {
'A' => [
[ 0x0644, 0x064A, 0x0647, 0x0645, 0x0627, 0x0628, 0x062A, 0x0643,
0x0644, 0x0645, 0x0648, 0x0634, 0x0639, 0x0631, 0x0628, 0x064A,
0x061F ].pack('U*'),
'egbpdaj6bu4bxfgehfvwxn'
],
'B' => [
[ 0x4ED6, 0x4EEC, 0x4E3A, 0x4EC0, 0x4E48, 0x4E0D, 0x8BF4, 0x4E2D,
0x6587 ].pack('U*'),
'ihqwcrb4cv8a8dqg056pqjye'
],
'C' => [
[ 0x4ED6, 0x5011, 0x7232, 0x4EC0, 0x9EBD, 0x4E0D, 0x8AAA, 0x4E2D,
0x6587 ].pack('U*'),
'ihqwctvzc91f659drss3x8bo0yb'
],
'D' => [
[ 0x0050, 0x0072, 0x006F, 0x010D, 0x0070, 0x0072, 0x006F, 0x0073,
0x0074, 0x011B, 0x006E, 0x0065, 0x006D, 0x006C, 0x0075, 0x0076,
0x00ED, 0x010D, 0x0065, 0x0073, 0x006B, 0x0079 ].pack('U*'),
'Proprostnemluvesky-uyb24dma41a'
],
'E' => [
[ 0x05DC, 0x05DE, 0x05D4, 0x05D4, 0x05DD, 0x05E4, 0x05E9, 0x05D5,
0x05D8, 0x05DC, 0x05D0, 0x05DE, 0x05D3, 0x05D1, 0x05E8, 0x05D9,
0x05DD, 0x05E2, 0x05D1, 0x05E8, 0x05D9, 0x05EA ].pack('U*'),
'4dbcagdahymbxekheh6e0a7fei0b'
],
'F' => [
[ 0x092F, 0x0939, 0x0932, 0x094B, 0x0917, 0x0939, 0x093F, 0x0928,
0x094D, 0x0926, 0x0940, 0x0915, 0x094D, 0x092F, 0x094B, 0x0902,
0x0928, 0x0939, 0x0940, 0x0902, 0x092C, 0x094B, 0x0932, 0x0938,
0x0915, 0x0924, 0x0947, 0x0939, 0x0948, 0x0902 ].pack('U*'),
'i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd'
],
'G' => [
[ 0x306A, 0x305C, 0x307F, 0x3093, 0x306A, 0x65E5, 0x672C, 0x8A9E,
0x3092, 0x8A71, 0x3057, 0x3066, 0x304F, 0x308C, 0x306A, 0x3044,
0x306E, 0x304B ].pack('U*'),
'n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa'
],
'H' => [
[ 0xC138, 0xACC4, 0xC758, 0xBAA8, 0xB4E0, 0xC0AC, 0xB78C, 0xB4E4,
0xC774, 0xD55C, 0xAD6D, 0xC5B4, 0xB97C, 0xC774, 0xD574, 0xD55C,
0xB2E4, 0xBA74, 0xC5BC, 0xB9C8, 0xB098, 0xC88B, 0xC744,
0xAE4C ].pack('U*'),
'989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c'
],
'I' => [
[ 0x043F, 0x043E, 0x0447, 0x0435, 0x043C, 0x0443, 0x0436, 0x0435,
0x043E, 0x043D, 0x0438, 0x043D, 0x0435, 0x0433, 0x043E, 0x0432,
0x043E, 0x0440, 0x044F, 0x0442, 0x043F, 0x043E, 0x0440, 0x0443,
0x0441, 0x0441, 0x043A, 0x0438 ].pack('U*'),
'b1abfaaepdrnnbgefbadotcwatmq2g4l'
],
'J' => [
[ 0x0050, 0x006F, 0x0072, 0x0071, 0x0075, 0x00E9, 0x006E, 0x006F,
0x0070, 0x0075, 0x0065, 0x0064, 0x0065, 0x006E, 0x0073, 0x0069,
0x006D, 0x0070, 0x006C, 0x0065, 0x006D, 0x0065, 0x006E, 0x0074,
0x0065, 0x0068, 0x0061, 0x0062, 0x006C, 0x0061, 0x0072, 0x0065,
0x006E, 0x0045, 0x0073, 0x0070, 0x0061, 0x00F1, 0x006F,
0x006C ].pack('U*'),
'PorqunopuedensimplementehablarenEspaol-fmd56a'
],
'K' => [
[ 0x0054, 0x1EA1, 0x0069, 0x0073, 0x0061, 0x006F, 0x0068, 0x1ECD,
0x006B, 0x0068, 0x00F4, 0x006E, 0x0067, 0x0074, 0x0068, 0x1EC3,
0x0063, 0x0068, 0x1EC9, 0x006E, 0x00F3, 0x0069, 0x0074, 0x0069,
0x1EBF, 0x006E, 0x0067, 0x0056, 0x0069, 0x1EC7, 0x0074 ].pack('U*'),
'TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g'
],
'L' => [
[ 0x0033, 0x5E74, 0x0042, 0x7D44, 0x91D1, 0x516B, 0x5148,
0x751F ].pack('U*'),
'3B-ww4c5e180e575a65lsy2b'
],
'M' => [
[ 0x5B89, 0x5BA4, 0x5948, 0x7F8E, 0x6075, 0x002D, 0x0077, 0x0069,
0x0074, 0x0068, 0x002D, 0x0053, 0x0055, 0x0050, 0x0045, 0x0052,
0x002D, 0x004D, 0x004F, 0x004E, 0x004B, 0x0045, 0x0059,
0x0053 ].pack('U*'),
'-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n'
],
'N' => [
[ 0x0048, 0x0065, 0x006C, 0x006C, 0x006F, 0x002D, 0x0041, 0x006E,
0x006F, 0x0074, 0x0068, 0x0065, 0x0072, 0x002D, 0x0057, 0x0061,
0x0079, 0x002D, 0x305D, 0x308C, 0x305E, 0x308C, 0x306E, 0x5834,
0x6240 ].pack('U*'),
'Hello-Another-Way--fc4qua05auwb3674vfr0b'
],
'O' => [
[ 0x3072, 0x3068, 0x3064, 0x5C4B, 0x6839, 0x306E, 0x4E0B,
0x0032 ].pack('U*'),
'2-u9tlzr9756bt3uc0v'
],
'P' => [
[ 0x004D, 0x0061, 0x006A, 0x0069, 0x3067, 0x004B, 0x006F, 0x0069,
0x3059, 0x308B, 0x0035, 0x79D2, 0x524D ].pack('U*'),
'MajiKoi5-783gue6qz075azm5e'
],
'Q' => [
[ 0x30D1, 0x30D5, 0x30A3, 0x30FC, 0x0064, 0x0065, 0x30EB, 0x30F3,
0x30D0 ].pack('U*'),
'de-jg4avhby1noc0d'
],
'R' => [
[ 0x305D, 0x306E, 0x30B9, 0x30D4, 0x30FC, 0x30C9, 0x3067 ].pack('U*'),
'd9juau41awczczp'
],
'S' => [
[ 0x002D, 0x003E, 0x0020, 0x0024, 0x0031, 0x002E, 0x0030, 0x0030,
0x0020, 0x003C, 0x002D ].pack('U*'),
'-> $1.00 <--'
]
}
def setup
end
def teardown
end
def test_encode_RFC3492
TESTCASES_RFC3492.each do |key, val|
rc = Punycode.encode(val[0])
assert_equal(val[1], rc, "TestCase #{key} failed")
end
end
def test_decode_RFC3492
TESTCASES_RFC3492.each do |key, val|
rc = Punycode.decode(val[1])
assert_equal(val[0], rc, "TestCase #{key} failed")
end
end
end
--- NEW FILE: tc_Idna.rb ---
# Unit tests for IDN::Idna.
#
# Copyright (c) 2005 Erik Abele. All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# Please see the file called LICENSE for further details.
#
# You may also obtain a copy of the License at
#
# * http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# This software is OSI Certified Open Source Software.
# OSI Certified is a certification mark of the Open Source Initiative.
require 'test/unit'
require 'idn'
class Test_Idna < Test::Unit::TestCase
include IDN
# JOSEFSSON test vectors, taken from DRAFT-JOSEFSSON-IDN-TEST-VECTORS-00:
# http://www.gnu.org/software/libidn/draft-josefsson-idn-test-vectors.html
#
# Modifications:
# - omission of 5.20 since it is identical with 5.8 (case H below)
TESTCASES_JOSEFSSON = {
'A' => [
[ 0x0644, 0x064A, 0x0647, 0x0645, 0x0627, 0x0628, 0x062A, 0x0643,
0x0644, 0x0645, 0x0648, 0x0634, 0x0639, 0x0631, 0x0628, 0x064A,
0x061F ].pack('U*'),
Idna::ACE_PREFIX + 'egbpdaj6bu4bxfgehfvwxn'
],
'B' => [
[ 0x4ED6, 0x4EEC, 0x4E3A, 0x4EC0, 0x4E48, 0x4E0D, 0x8BF4, 0x4E2D,
0x6587 ].pack('U*'),
Idna::ACE_PREFIX + 'ihqwcrb4cv8a8dqg056pqjye'
],
'C' => [
[ 0x4ED6, 0x5011, 0x7232, 0x4EC0, 0x9EBD, 0x4E0D, 0x8AAA, 0x4E2D,
0x6587 ].pack('U*'),
Idna::ACE_PREFIX + 'ihqwctvzc91f659drss3x8bo0yb'
],
'D' => [
[ 0x0050, 0x0072, 0x006F, 0x010D, 0x0070, 0x0072, 0x006F, 0x0073,
0x0074, 0x011B, 0x006E, 0x0065, 0x006D, 0x006C, 0x0075, 0x0076,
0x00ED, 0x010D, 0x0065, 0x0073, 0x006B, 0x0079 ].pack('U*'),
Idna::ACE_PREFIX + 'Proprostnemluvesky-uyb24dma41a'
],
'E' => [
[ 0x05DC, 0x05DE, 0x05D4, 0x05D4, 0x05DD, 0x05E4, 0x05E9, 0x05D5,
0x05D8, 0x05DC, 0x05D0, 0x05DE, 0x05D3, 0x05D1, 0x05E8, 0x05D9,
0x05DD, 0x05E2, 0x05D1, 0x05E8, 0x05D9, 0x05EA ].pack('U*'),
Idna::ACE_PREFIX + '4dbcagdahymbxekheh6e0a7fei0b'
],
'F' => [
[ 0x092F, 0x0939, 0x0932, 0x094B, 0x0917, 0x0939, 0x093F, 0x0928,
0x094D, 0x0926, 0x0940, 0x0915, 0x094D, 0x092F, 0x094B, 0x0902,
0x0928, 0x0939, 0x0940, 0x0902, 0x092C, 0x094B, 0x0932, 0x0938,
0x0915, 0x0924, 0x0947, 0x0939, 0x0948, 0x0902 ].pack('U*'),
Idna::ACE_PREFIX + 'i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd'
],
'G' => [
[ 0x306A, 0x305C, 0x307F, 0x3093, 0x306A, 0x65E5, 0x672C, 0x8A9E,
0x3092, 0x8A71, 0x3057, 0x3066, 0x304F, 0x308C, 0x306A, 0x3044,
0x306E, 0x304B ].pack('U*'),
Idna::ACE_PREFIX + 'n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa'
],
'H' => [
[ 0x043F, 0x043E, 0x0447, 0x0435, 0x043C, 0x0443, 0x0436, 0x0435,
0x043E, 0x043D, 0x0438, 0x043D, 0x0435, 0x0433, 0x043E, 0x0432,
0x043E, 0x0440, 0x044F, 0x0442, 0x043F, 0x043E, 0x0440, 0x0443,
0x0441, 0x0441, 0x043A, 0x0438 ].pack('U*'),
Idna::ACE_PREFIX + 'b1abfaaepdrnnbgefbadotcwatmq2g4l'
],
'I' => [
[ 0x0050, 0x006F, 0x0072, 0x0071, 0x0075, 0x00E9, 0x006E, 0x006F,
0x0070, 0x0075, 0x0065, 0x0064, 0x0065, 0x006E, 0x0073, 0x0069,
0x006D, 0x0070, 0x006C, 0x0065, 0x006D, 0x0065, 0x006E, 0x0074,
0x0065, 0x0068, 0x0061, 0x0062, 0x006C, 0x0061, 0x0072, 0x0065,
0x006E, 0x0045, 0x0073, 0x0070, 0x0061, 0x00F1, 0x006F,
0x006C ].pack('U*'),
Idna::ACE_PREFIX + 'PorqunopuedensimplementehablarenEspaol-fmd56a'
],
'J' => [
[ 0x0054, 0x1EA1, 0x0069, 0x0073, 0x0061, 0x006F, 0x0068, 0x1ECD,
0x006B, 0x0068, 0x00F4, 0x006E, 0x0067, 0x0074, 0x0068, 0x1EC3,
0x0063, 0x0068, 0x1EC9, 0x006E, 0x00F3, 0x0069, 0x0074, 0x0069,
0x1EBF, 0x006E, 0x0067, 0x0056, 0x0069, 0x1EC7, 0x0074 ].pack('U*'),
Idna::ACE_PREFIX + 'TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g'
],
'K' => [
[ 0x0033, 0x5E74, 0x0042, 0x7D44, 0x91D1, 0x516B, 0x5148,
0x751F ].pack('U*'),
Idna::ACE_PREFIX + '3B-ww4c5e180e575a65lsy2b'
],
'L' => [
[ 0x5B89, 0x5BA4, 0x5948, 0x7F8E, 0x6075, 0x002D, 0x0077, 0x0069,
0x0074, 0x0068, 0x002D, 0x0053, 0x0055, 0x0050, 0x0045, 0x0052,
0x002D, 0x004D, 0x004F, 0x004E, 0x004B, 0x0045, 0x0059,
0x0053 ].pack('U*'),
Idna::ACE_PREFIX + '-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n'
],
'M' => [
[ 0x0048, 0x0065, 0x006C, 0x006C, 0x006F, 0x002D, 0x0041, 0x006E,
0x006F, 0x0074, 0x0068, 0x0065, 0x0072, 0x002D, 0x0057, 0x0061,
0x0079, 0x002D, 0x305D, 0x308C, 0x305E, 0x308C, 0x306E, 0x5834,
0x6240 ].pack('U*'),
Idna::ACE_PREFIX + 'Hello-Another-Way--fc4qua05auwb3674vfr0b'
],
'N' => [
[ 0x3072, 0x3068, 0x3064, 0x5C4B, 0x6839, 0x306E, 0x4E0B,
0x0032 ].pack('U*'),
Idna::ACE_PREFIX + '2-u9tlzr9756bt3uc0v'
],
'O' => [
[ 0x004D, 0x0061, 0x006A, 0x0069, 0x3067, 0x004B, 0x006F, 0x0069,
0x3059, 0x308B, 0x0035, 0x79D2, 0x524D ].pack('U*'),
Idna::ACE_PREFIX + 'MajiKoi5-783gue6qz075azm5e'
],
'P' => [
[ 0x30D1, 0x30D5, 0x30A3, 0x30FC, 0x0064, 0x0065, 0x30EB, 0x30F3,
0x30D0 ].pack('U*'),
Idna::ACE_PREFIX + 'de-jg4avhby1noc0d'
],
'Q' => [
[ 0x305D, 0x306E, 0x30B9, 0x30D4, 0x30FC, 0x30C9, 0x3067 ].pack('U*'),
Idna::ACE_PREFIX + 'd9juau41awczczp'
],
'R' => [
[ 0x03B5, 0x03BB, 0x03BB, 0x03B7, 0x03BD, 0x03B9, 0x03BA,
0x03AC ].pack('U*'),
Idna::ACE_PREFIX + 'hxargifdar'
],
'S' => [
[ 0x0062, 0x006F, 0x006E, 0x0121, 0x0075, 0x0073, 0x0061, 0x0127,
0x0127, 0x0061 ].pack('U*'),
Idna::ACE_PREFIX + 'bonusaa-5bb1da'
]
}
# UNASSIGNED test vectors: unassigned code points U+0221 and U+0236.
TESTCASES_UNASSIGNED = {
'A' => [
[ 0x0221 ].pack('U*'),
Idna::ACE_PREFIX + '6la'
],
'B' => [
[ 0x0236 ].pack('U*'),
Idna::ACE_PREFIX + 'sma'
]
}
# STD3 test vectors: labels not conforming to the STD3 ASCII rules (see
# RFC1122 and RFC1123 for details).
TESTCASES_STD3 = {
'A' => [
[ 0x0115, 0x0073, 0x0074, 0x0065, 0x002D ].pack('U*'),
Idna::ACE_PREFIX + 'ste--kva'
],
'B' => [
[ 0x006F, 0x003A, 0x006C, 0x006B, 0x01EB, 0x0065 ].pack('U*'),
Idna::ACE_PREFIX + 'o:lke-m1b'
]
}
def setup
end
def teardown
end
def test_toASCII_JOSEFSSON
TESTCASES_JOSEFSSON.each do |key, val|
rc = Idna.toASCII(val[0])
assert_equal(val[1].downcase, rc, "TestCase #{key} failed")
end
end
def test_toASCII_UNASSIGNED_ALLOWED
TESTCASES_UNASSIGNED.each do |key, val|
assert_nothing_raised("TestCase #{key} failed") do
Idna.toASCII(val[0], IDN::Idna::ALLOW_UNASSIGNED)
end
end
end
def test_toASCII_UNASSIGNED_NOT_ALLOWED
TESTCASES_UNASSIGNED.each do |key, val|
assert_raise(Idna::IdnaError, "TestCase #{key} failed") do
Idna.toASCII(val[0])
end
end
end
def test_toASCII_STD3_USED
TESTCASES_STD3.each do |key, val|
assert_raise(Idna::IdnaError, "TestCase #{key} failed") do
Idna.toASCII(val[0], IDN::Idna::USE_STD3_ASCII_RULES)
end
end
end
def test_toASCII_STD3_NOT_USED
TESTCASES_STD3.each do |key, val|
assert_nothing_raised("TestCase #{key} failed") do
Idna.toASCII(val[0])
end
end
end
def test_toUnicode_JOSEFSSON
TESTCASES_JOSEFSSON.each do |key, val|
rc = Idna.toUnicode(val[1])
assert_equal(val[0], rc, "TestCase #{key} failed")
end
end
def test_toUnicode_UNASSIGNED_ALLOWED
TESTCASES_UNASSIGNED.each do |key, val|
rc = Idna.toUnicode(val[1], IDN::Idna::ALLOW_UNASSIGNED)
assert_equal(val[0], rc, "TestCase #{key} failed")
end
end
def test_toUnicode_UNASSIGNED_NOT_ALLOWED
TESTCASES_UNASSIGNED.each do |key, val|
rc = Idna.toUnicode(val[1])
assert_equal(val[1], rc, "TestCase #{key} failed")
end
end
def test_toUnicode_STD3_USED
TESTCASES_STD3.each do |key, val|
rc = Idna.toUnicode(val[1], IDN::Idna::USE_STD3_ASCII_RULES)
assert_equal(val[1], rc, "TestCase #{key} failed")
end
end
def test_toUnicode_STD3_NOT_USED
TESTCASES_STD3.each do |key, val|
rc = Idna.toUnicode(val[1])
assert_equal(val[0], rc, "TestCase #{key} failed")
end
end
end