idn 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,188 @@
1
+ # Unit tests for IDN::Punycode.
2
+ #
3
+ # Copyright (c) 2005 Erik Abele. All rights reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # Please see the file called LICENSE for further details.
8
+ #
9
+ # You may also obtain a copy of the License at
10
+ #
11
+ # * http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+ # This software is OSI Certified Open Source Software.
20
+ # OSI Certified is a certification mark of the Open Source Initiative.
21
+
22
+ require 'test/unit'
23
+ require 'idn'
24
+
25
+ class Test_Punycode < Test::Unit::TestCase
26
+ include IDN
27
+
28
+ # RFC3492 test vectors, taken from RFC3492 (7.1 Sample Strings):
29
+ # http://www.ietf.org/rfc/rfc3492.txt
30
+ #
31
+ # Modifications:
32
+ # - correction of an obviously wrong uppercase character in case I
33
+
34
+ TESTCASES_RFC3492 = {
35
+ 'A' => [
36
+ [ 0x0644, 0x064A, 0x0647, 0x0645, 0x0627, 0x0628, 0x062A, 0x0643,
37
+ 0x0644, 0x0645, 0x0648, 0x0634, 0x0639, 0x0631, 0x0628, 0x064A,
38
+ 0x061F ].pack('U*'),
39
+ 'egbpdaj6bu4bxfgehfvwxn'
40
+ ],
41
+
42
+ 'B' => [
43
+ [ 0x4ED6, 0x4EEC, 0x4E3A, 0x4EC0, 0x4E48, 0x4E0D, 0x8BF4, 0x4E2D,
44
+ 0x6587 ].pack('U*'),
45
+ 'ihqwcrb4cv8a8dqg056pqjye'
46
+ ],
47
+
48
+ 'C' => [
49
+ [ 0x4ED6, 0x5011, 0x7232, 0x4EC0, 0x9EBD, 0x4E0D, 0x8AAA, 0x4E2D,
50
+ 0x6587 ].pack('U*'),
51
+ 'ihqwctvzc91f659drss3x8bo0yb'
52
+ ],
53
+
54
+ 'D' => [
55
+ [ 0x0050, 0x0072, 0x006F, 0x010D, 0x0070, 0x0072, 0x006F, 0x0073,
56
+ 0x0074, 0x011B, 0x006E, 0x0065, 0x006D, 0x006C, 0x0075, 0x0076,
57
+ 0x00ED, 0x010D, 0x0065, 0x0073, 0x006B, 0x0079 ].pack('U*'),
58
+ 'Proprostnemluvesky-uyb24dma41a'
59
+ ],
60
+
61
+ 'E' => [
62
+ [ 0x05DC, 0x05DE, 0x05D4, 0x05D4, 0x05DD, 0x05E4, 0x05E9, 0x05D5,
63
+ 0x05D8, 0x05DC, 0x05D0, 0x05DE, 0x05D3, 0x05D1, 0x05E8, 0x05D9,
64
+ 0x05DD, 0x05E2, 0x05D1, 0x05E8, 0x05D9, 0x05EA ].pack('U*'),
65
+ '4dbcagdahymbxekheh6e0a7fei0b'
66
+ ],
67
+
68
+ 'F' => [
69
+ [ 0x092F, 0x0939, 0x0932, 0x094B, 0x0917, 0x0939, 0x093F, 0x0928,
70
+ 0x094D, 0x0926, 0x0940, 0x0915, 0x094D, 0x092F, 0x094B, 0x0902,
71
+ 0x0928, 0x0939, 0x0940, 0x0902, 0x092C, 0x094B, 0x0932, 0x0938,
72
+ 0x0915, 0x0924, 0x0947, 0x0939, 0x0948, 0x0902 ].pack('U*'),
73
+ 'i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd'
74
+ ],
75
+
76
+ 'G' => [
77
+ [ 0x306A, 0x305C, 0x307F, 0x3093, 0x306A, 0x65E5, 0x672C, 0x8A9E,
78
+ 0x3092, 0x8A71, 0x3057, 0x3066, 0x304F, 0x308C, 0x306A, 0x3044,
79
+ 0x306E, 0x304B ].pack('U*'),
80
+ 'n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa'
81
+ ],
82
+
83
+ 'H' => [
84
+ [ 0xC138, 0xACC4, 0xC758, 0xBAA8, 0xB4E0, 0xC0AC, 0xB78C, 0xB4E4,
85
+ 0xC774, 0xD55C, 0xAD6D, 0xC5B4, 0xB97C, 0xC774, 0xD574, 0xD55C,
86
+ 0xB2E4, 0xBA74, 0xC5BC, 0xB9C8, 0xB098, 0xC88B, 0xC744,
87
+ 0xAE4C ].pack('U*'),
88
+ '989aomsvi5e83db1d2a355cv1e0vak1dwrv93d5xbh15a0dt30a5jpsd879ccm6fea98c'
89
+ ],
90
+
91
+ 'I' => [
92
+ [ 0x043F, 0x043E, 0x0447, 0x0435, 0x043C, 0x0443, 0x0436, 0x0435,
93
+ 0x043E, 0x043D, 0x0438, 0x043D, 0x0435, 0x0433, 0x043E, 0x0432,
94
+ 0x043E, 0x0440, 0x044F, 0x0442, 0x043F, 0x043E, 0x0440, 0x0443,
95
+ 0x0441, 0x0441, 0x043A, 0x0438 ].pack('U*'),
96
+ 'b1abfaaepdrnnbgefbadotcwatmq2g4l'
97
+ ],
98
+
99
+ 'J' => [
100
+ [ 0x0050, 0x006F, 0x0072, 0x0071, 0x0075, 0x00E9, 0x006E, 0x006F,
101
+ 0x0070, 0x0075, 0x0065, 0x0064, 0x0065, 0x006E, 0x0073, 0x0069,
102
+ 0x006D, 0x0070, 0x006C, 0x0065, 0x006D, 0x0065, 0x006E, 0x0074,
103
+ 0x0065, 0x0068, 0x0061, 0x0062, 0x006C, 0x0061, 0x0072, 0x0065,
104
+ 0x006E, 0x0045, 0x0073, 0x0070, 0x0061, 0x00F1, 0x006F,
105
+ 0x006C ].pack('U*'),
106
+ 'PorqunopuedensimplementehablarenEspaol-fmd56a'
107
+ ],
108
+
109
+ 'K' => [
110
+ [ 0x0054, 0x1EA1, 0x0069, 0x0073, 0x0061, 0x006F, 0x0068, 0x1ECD,
111
+ 0x006B, 0x0068, 0x00F4, 0x006E, 0x0067, 0x0074, 0x0068, 0x1EC3,
112
+ 0x0063, 0x0068, 0x1EC9, 0x006E, 0x00F3, 0x0069, 0x0074, 0x0069,
113
+ 0x1EBF, 0x006E, 0x0067, 0x0056, 0x0069, 0x1EC7, 0x0074 ].pack('U*'),
114
+ 'TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g'
115
+ ],
116
+
117
+ 'L' => [
118
+ [ 0x0033, 0x5E74, 0x0042, 0x7D44, 0x91D1, 0x516B, 0x5148,
119
+ 0x751F ].pack('U*'),
120
+ '3B-ww4c5e180e575a65lsy2b'
121
+ ],
122
+
123
+ 'M' => [
124
+ [ 0x5B89, 0x5BA4, 0x5948, 0x7F8E, 0x6075, 0x002D, 0x0077, 0x0069,
125
+ 0x0074, 0x0068, 0x002D, 0x0053, 0x0055, 0x0050, 0x0045, 0x0052,
126
+ 0x002D, 0x004D, 0x004F, 0x004E, 0x004B, 0x0045, 0x0059,
127
+ 0x0053 ].pack('U*'),
128
+ '-with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n'
129
+ ],
130
+
131
+ 'N' => [
132
+ [ 0x0048, 0x0065, 0x006C, 0x006C, 0x006F, 0x002D, 0x0041, 0x006E,
133
+ 0x006F, 0x0074, 0x0068, 0x0065, 0x0072, 0x002D, 0x0057, 0x0061,
134
+ 0x0079, 0x002D, 0x305D, 0x308C, 0x305E, 0x308C, 0x306E, 0x5834,
135
+ 0x6240 ].pack('U*'),
136
+ 'Hello-Another-Way--fc4qua05auwb3674vfr0b'
137
+ ],
138
+
139
+ 'O' => [
140
+ [ 0x3072, 0x3068, 0x3064, 0x5C4B, 0x6839, 0x306E, 0x4E0B,
141
+ 0x0032 ].pack('U*'),
142
+ '2-u9tlzr9756bt3uc0v'
143
+ ],
144
+
145
+ 'P' => [
146
+ [ 0x004D, 0x0061, 0x006A, 0x0069, 0x3067, 0x004B, 0x006F, 0x0069,
147
+ 0x3059, 0x308B, 0x0035, 0x79D2, 0x524D ].pack('U*'),
148
+ 'MajiKoi5-783gue6qz075azm5e'
149
+ ],
150
+
151
+ 'Q' => [
152
+ [ 0x30D1, 0x30D5, 0x30A3, 0x30FC, 0x0064, 0x0065, 0x30EB, 0x30F3,
153
+ 0x30D0 ].pack('U*'),
154
+ 'de-jg4avhby1noc0d'
155
+ ],
156
+
157
+ 'R' => [
158
+ [ 0x305D, 0x306E, 0x30B9, 0x30D4, 0x30FC, 0x30C9, 0x3067 ].pack('U*'),
159
+ 'd9juau41awczczp'
160
+ ],
161
+
162
+ 'S' => [
163
+ [ 0x002D, 0x003E, 0x0020, 0x0024, 0x0031, 0x002E, 0x0030, 0x0030,
164
+ 0x0020, 0x003C, 0x002D ].pack('U*'),
165
+ '-> $1.00 <--'
166
+ ]
167
+ }
168
+
169
+ def setup
170
+ end
171
+
172
+ def teardown
173
+ end
174
+
175
+ def test_encode_RFC3492
176
+ TESTCASES_RFC3492.each do |key, val|
177
+ rc = Punycode.encode(val[0])
178
+ assert_equal(val[1], rc, "TestCase #{key} failed")
179
+ end
180
+ end
181
+
182
+ def test_decode_RFC3492
183
+ TESTCASES_RFC3492.each do |key, val|
184
+ rc = Punycode.decode(val[1])
185
+ assert_equal(val[0], rc, "TestCase #{key} failed")
186
+ end
187
+ end
188
+ end
@@ -0,0 +1,66 @@
1
+ # Unit tests for IDN::Stringprep.
2
+ #
3
+ # Copyright (c) 2005 Erik Abele. All rights reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # Please see the file called LICENSE for further details.
8
+ #
9
+ # You may also obtain a copy of the License at
10
+ #
11
+ # * http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+ # This software is OSI Certified Open Source Software.
20
+ # OSI Certified is a certification mark of the Open Source Initiative.
21
+
22
+ require 'test/unit'
23
+ require 'idn'
24
+
25
+ class Test_Stringprep < Test::Unit::TestCase
26
+ include IDN
27
+
28
+ # STRINGPREP test vectors: UTF-8 encoded strings and the corresponding
29
+ # prepared form, according to the given profile.
30
+
31
+ TESTCASES_STRINGPREP = {
32
+ 'A' => [ "Nameprep", "\xC5\x83\xCD\xBA", "\xC5\x84 \xCE\xB9" ],
33
+ 'B' => [ "Nodeprep", "\xE1\xBE\xB7", "\xE1\xBE\xB6\xCE\xB9" ],
34
+ 'C' => [ "Resourceprep", "foo@bar", "foo@bar" ],
35
+ 'D' => [ "ISCSIprep", "Example-Name", "example-name" ],
36
+ 'E' => [ "SASLprep", "Example\xC2\xA0Name", "Example Name" ]
37
+ }
38
+
39
+ # NFKC test vectors: UTF-8 encoded strings and the corresponding
40
+ # normalized form, according to NFKC normalization mode.
41
+
42
+ TESTCASES_NFKC = {
43
+ 'A' => [ "\xC2\xB5", "\xCE\xBC" ],
44
+ 'B' => [ "\xC2\xAA", "\x61" ]
45
+ }
46
+
47
+ def setup
48
+ end
49
+
50
+ def teardown
51
+ end
52
+
53
+ def test_with_profile
54
+ TESTCASES_STRINGPREP.each do |key, val|
55
+ rc = Stringprep.with_profile(val[1], val[0])
56
+ assert_equal(val[2], rc, "TestCase #{key} failed")
57
+ end
58
+ end
59
+
60
+ def test_nfkc_normalize
61
+ TESTCASES_NFKC.each do |key, val|
62
+ rc = Stringprep.nfkc_normalize(val[0])
63
+ assert_equal(val[1], rc, "TestCase #{key} failed")
64
+ end
65
+ end
66
+ end
@@ -0,0 +1,31 @@
1
+ # Test suite for LibIDN Ruby Bindings.
2
+ #
3
+ # Copyright (c) 2005 Erik Abele. All rights reserved.
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # Please see the file called LICENSE for further details.
8
+ #
9
+ # You may also obtain a copy of the License at
10
+ #
11
+ # * http://www.apache.org/licenses/LICENSE-2.0
12
+ #
13
+ # Unless required by applicable law or agreed to in writing, software
14
+ # distributed under the License is distributed on an "AS IS" BASIS,
15
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ # See the License for the specific language governing permissions and
17
+ # limitations under the License.
18
+ #
19
+ # This software is OSI Certified Open Source Software.
20
+ # OSI Certified is a certification mark of the Open Source Initiative.
21
+
22
+ require 'test/unit'
23
+
24
+ # Construct absolute project path.
25
+ project_path = File.join(File.dirname(__FILE__), '..')
26
+
27
+ # Add project directories to global LOAD_PATH ($:).
28
+ $:.unshift File.join(project_path, 'ext'), File.join(project_path, 'lib')
29
+
30
+ # Require all testcase files.
31
+ Dir[File.join(project_path, 'test', 'tc_*.rb')].each { |tc| require tc }
metadata ADDED
@@ -0,0 +1,74 @@
1
+ --- !ruby/object:Gem::Specification
2
+ rubygems_version: 0.8.11
3
+ specification_version: 1
4
+ name: idn
5
+ version: !ruby/object:Gem::Version
6
+ version: 0.0.1
7
+ date: 2005-09-26 00:00:00 +02:00
8
+ summary: LibIDN Ruby Bindings
9
+ require_paths:
10
+ - lib
11
+ email: erikabele@rubyforge.org
12
+ homepage: http://rubyforge.org/projects/idn/
13
+ rubyforge_project: idn
14
+ description: "Ruby Bindings for the GNU LibIDN library, an implementation of the Stringprep,
15
+ Punycode and IDNA specifications defined by the IETF Internationalized Domain
16
+ Names (IDN) working group. Included are the most important parts of the
17
+ Stringprep, Punycode and IDNA APIs like performing Stringprep processings,
18
+ encoding to and decoding from Punycode strings and converting entire domain
19
+ names to and from the ACE encoded form."
20
+ autorequire: idn
21
+ default_executable:
22
+ bindir: bin
23
+ has_rdoc: true
24
+ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
+ requirements:
26
+ -
27
+ - ">"
28
+ - !ruby/object:Gem::Version
29
+ version: 0.0.0
30
+ version:
31
+ platform: ruby
32
+ signing_key:
33
+ cert_chain:
34
+ authors:
35
+ - Erik Abele
36
+ files:
37
+ - README
38
+ - CHANGES
39
+ - LICENSE
40
+ - NOTICE
41
+ - Rakefile
42
+ - ext/idn.c
43
+ - ext/idna.c
44
+ - ext/punycode.c
45
+ - ext/stringprep.c
46
+ - ext/idn.h
47
+ - ext/extconf.rb
48
+ - test/tc_Idna.rb
49
+ - test/tc_Punycode.rb
50
+ - test/tc_Stringprep.rb
51
+ - test/ts_IDN.rb
52
+ test_files:
53
+ - test/ts_IDN.rb
54
+ rdoc_options:
55
+ - "-m"
56
+ - README
57
+ - "-t"
58
+ - LibIDN Ruby Bindings Documentation
59
+ - "-N"
60
+ - "-S"
61
+ - "-w 2"
62
+ extra_rdoc_files:
63
+ - README
64
+ - CHANGES
65
+ - LICENSE
66
+ - ext/idna.c
67
+ - ext/punycode.c
68
+ - ext/stringprep.c
69
+ - ext/idn.c
70
+ executables: []
71
+ extensions:
72
+ - ext/extconf.rb
73
+ requirements: []
74
+ dependencies: []