simpleidn 0.0.5 → 0.0.6

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3615b258493fcee8e713034665e394f297ad481d
4
- data.tar.gz: 6dfae265394af03eef4b87fe2eabba1c751d6192
3
+ metadata.gz: 6282e8801d789394c2e062b0bcab6f1e83807b23
4
+ data.tar.gz: 98036f912ff1374c176827c36a316295e6c852c3
5
5
  SHA512:
6
- metadata.gz: 4fbb98432795f655e850c43fe3001171bda768901e134fb2eb3f17538f4eb00898c18565d83c46b9f6a619039aa89ac1bc02a86824de30ba65d1de2b280436c6
7
- data.tar.gz: 9ec44eb275d66b009f9af1a394d5d6d6531bad824073fbb70544f67d6c5b76ae5b6e3cdbf861bccd008c8a4154f3187ac1f8d031a53499613a0d98da3543033c
6
+ metadata.gz: fcd5128a0e2d19f485f78aa44b29c9901e63fb14671d1b20cea62412bf374d0820bda175537a9127233e07ec5bc931eaa7b6b4049bac627456c728db0ba4eab7
7
+ data.tar.gz: 702f08322b85fabcd5210d10b021f42946003a00cb787843f32f8c820dc92bf6183c48f345c88d5f6d8741048c95d330f5fe2f0a2411ab714b50a1936b9bcce6
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ # Bundler
2
+ .bundle
3
+ pkg/*
4
+ Gemfile.lock
5
+
6
+ .rvmrc
7
+ .rbenv-version
8
+ doc
9
+ spec/*.yml
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'https://rubygems.org'
2
+
3
+ gemspec
data/README.rdoc CHANGED
@@ -4,7 +4,7 @@ This gem allows easy conversion from punycode ACE strings to unicode UTF-8 strin
4
4
 
5
5
  The implementation is heavily based on the RFC3492 C example implementation but simplified since it does not preserve case.
6
6
 
7
- This gem works with both Ruby 1.8.7, 1.9.2, 1.9.3 and 2.0.
7
+ This gem works with Ruby 1.8.7, 1.9.2, 1.9.3, 2.0, 2.1, 2.2.
8
8
 
9
9
  * http://www.whatastruggle.com
10
10
 
data/Rakefile CHANGED
@@ -1,13 +1,6 @@
1
- # encoding: utf-8
2
- require 'rubygems'
3
- require 'rake'
4
- require 'echoe'
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
5
3
 
6
- Echoe.new('simpleidn', '0.0.5') do |p|
7
- p.description = "This gem allows easy conversion from punycode ACE strings to unicode UTF-8 strings and visa versa."
8
- p.url = "http://github.com/mmriis/simpleidn"
9
- p.author = "Morten Møller Riis"
10
- p.email = "mortenmoellerriis _AT_ gmail.com"
11
- p.ignore_pattern = ["tmp/*", "script/*"]
12
- end
4
+ RSpec::Core::RakeTask.new(:spec)
13
5
 
6
+ task :default => :spec
data/lib/simpleidn.rb CHANGED
@@ -7,7 +7,7 @@ if RUBY_VERSION =~ /^1\.8/
7
7
  end
8
8
  end
9
9
  else
10
- Encoding.default_internal = "UTF-8"
10
+ Encoding.default_internal = "UTF-8"
11
11
  end
12
12
 
13
13
  class Integer
@@ -17,9 +17,16 @@ class Integer
17
17
  end
18
18
 
19
19
  module SimpleIDN
20
-
20
+
21
+ VERSION = "0.0.6"
22
+
23
+ # The ConversionError is raised when an error occurs during a
24
+ # Punycode <-> Unicode conversion.
25
+ class ConversionError < RangeError
26
+ end
27
+
21
28
  module Punycode
22
-
29
+
23
30
  INITIAL_N = 0x80
24
31
  INITIAL_BIAS = 72
25
32
  DELIMITER = 0x2D
@@ -30,26 +37,26 @@ module SimpleIDN
30
37
  SKEW = 38
31
38
  MAXINT = 0x7FFFFFFF
32
39
 
33
- module_function
34
-
35
- # decode_digit(cp) returns the numeric value of a basic code
40
+ module_function
41
+
42
+ # decode_digit(cp) returns the numeric value of a basic code
36
43
  # point (for use in representing integers) in the range 0 to
37
- # base-1, or base if cp is does not represent a value.
44
+ # base-1, or base if cp is does not represent a value.
38
45
  def decode_digit(cp)
39
46
  cp - 48 < 10 ? cp - 22 : cp - 65 < 26 ? cp - 65 : cp - 97 < 26 ? cp - 97 : BASE
40
47
  end
41
-
48
+
42
49
  # encode_digit(d,flag) returns the basic code point whose value
43
50
  # (when used for representing integers) is d, which needs to be in
44
51
  # the range 0 to base-1. The lowercase form is used unless flag is
45
52
  # nonzero, in which case the uppercase form is used. The behavior
46
- # is undefined if flag is nonzero and digit d has no uppercase form.
53
+ # is undefined if flag is nonzero and digit d has no uppercase form.
47
54
  def encode_digit(d)
48
55
  d + 22 + 75 * (d < 26 ? 1 : 0)
49
- # 0..25 map to ASCII a..z or A..Z
56
+ # 0..25 map to ASCII a..z or A..Z
50
57
  # 26..35 map to ASCII 0..9
51
58
  end
52
-
59
+
53
60
  # Bias adaptation function
54
61
  def adapt(delta, numpoints, firsttime)
55
62
  delta = firsttime ? (delta / DAMP) : (delta >> 1)
@@ -62,7 +69,7 @@ module SimpleIDN
62
69
  end
63
70
  return k + (BASE - TMIN + 1) * delta / (delta + SKEW)
64
71
  end
65
-
72
+
66
73
  # encode_basic(bcp,flag) forces a basic code point to lowercase if flag is zero,
67
74
  # uppercase if flag is nonzero, and returns the resulting code point.
68
75
  # The code point is unchanged if it is caseless.
@@ -71,28 +78,28 @@ module SimpleIDN
71
78
  bcp -= (bcp - 97 < 26 ? 1 : 0) << 5
72
79
  return bcp + ((!flag && (bcp - 65 < 26 ? 1 : 0)) << 5)
73
80
  end
74
-
81
+
75
82
  # Main decode
76
83
  def decode(input)
77
84
  output = []
78
85
 
79
- # Initialize the state:
86
+ # Initialize the state:
80
87
  n = INITIAL_N
81
88
  i = 0
82
89
  bias = INITIAL_BIAS
83
90
 
84
- # Handle the basic code points: Let basic be the number of input code
91
+ # Handle the basic code points: Let basic be the number of input code
85
92
  # points before the last delimiter, or 0 if there is none, then
86
93
  # copy the first basic code points to the output.
87
94
  basic = input.rindex(DELIMITER.to_utf8_character) || 0
88
95
 
89
96
  input.unpack("U*")[0, basic].each do |char|
90
- raise(RangeError, "Illegal input >= 0x80") if char >= 0x80
97
+ raise(ConversionError, "Illegal input >= 0x80") if char >= 0x80
91
98
  output << char.chr # to_utf8_character not needed her because ord < 0x80 (128) which is within US-ASCII.
92
99
  end
93
100
 
94
101
  # Main decoding loop: Start just after the last delimiter if any
95
- # basic code points were copied; start at the beginning otherwise.
102
+ # basic code points were copied; start at the beginning otherwise.
96
103
 
97
104
  ic = basic > 0 ? basic + 1 : 0
98
105
  while ic < input.length do
@@ -100,26 +107,26 @@ module SimpleIDN
100
107
 
101
108
  # Decode a generalized variable-length integer into delta,
102
109
  # which gets added to i. The overflow checking is easier
103
- # if we increase i as we go, then subtract off its starting
110
+ # if we increase i as we go, then subtract off its starting
104
111
  # value at the end to obtain delta.
105
112
  oldi = i
106
113
  w = 1
107
114
  k = BASE
108
115
  while true do
109
- raise(RangeError, "punycode_bad_input(1)") if ic >= input.length
116
+ raise(ConversionError, "punycode_bad_input(1)") if ic >= input.length
110
117
 
111
118
  digit = decode_digit(input[ic].ord)
112
119
  ic += 1
113
120
 
114
- raise(RangeError, "punycode_bad_input(2)") if digit >= BASE
115
-
116
- raise(RangeError, "punycode_overflow(1)") if digit > (MAXINT - i) / w
121
+ raise(ConversionError, "punycode_bad_input(2)") if digit >= BASE
122
+
123
+ raise(ConversionError, "punycode_overflow(1)") if digit > (MAXINT - i) / w
117
124
 
118
125
  i += digit * w
119
126
  t = k <= bias ? TMIN : k >= bias + TMAX ? TMAX : k - bias
120
127
  break if digit < t
121
- raise(RangeError, "punycode_overflow(2)") if w > MAXINT / (BASE - t)
122
-
128
+ raise(ConversionError, "punycode_overflow(2)") if w > MAXINT / (BASE - t)
129
+
123
130
  w *= BASE - t
124
131
  k += BASE
125
132
  end
@@ -128,58 +135,57 @@ module SimpleIDN
128
135
  bias = adapt(i - oldi, out, oldi == 0)
129
136
 
130
137
  # i was supposed to wrap around from out to 0,
131
- # incrementing n each time, so we'll fix that now:
132
- raise(RangeError, "punycode_overflow(3)") if (i / out) > MAXINT - n
138
+ # incrementing n each time, so we'll fix that now:
139
+ raise(ConversionError, "punycode_overflow(3)") if (i / out) > MAXINT - n
133
140
 
134
141
  n += (i / out)
135
142
  i %= out
136
143
 
137
- # Insert n at position i of the output:
144
+ # Insert n at position i of the output:
138
145
  output.insert(i, n.to_utf8_character)
139
146
  i += 1
140
147
  end
141
-
148
+
142
149
  return output.join
143
150
  end
144
151
 
145
152
  # Main encode function
146
153
  def encode(input)
147
-
148
154
  input = input.downcase.unpack("U*")
149
155
  output = []
150
156
 
151
- # Initialize the state:
157
+ # Initialize the state:
152
158
  n = INITIAL_N
153
159
  delta = 0
154
160
  bias = INITIAL_BIAS
155
161
 
156
- # Handle the basic code points:
162
+ # Handle the basic code points:
157
163
  output = input.select do |char|
158
164
  char if char < 0x80
159
165
  end
160
-
166
+
161
167
  h = b = output.length
162
168
 
163
169
  # h is the number of code points that have been handled, b is the
164
- # number of basic code points
170
+ # number of basic code points
165
171
 
166
172
  output << DELIMITER if b > 0
167
173
 
168
174
  # Main encoding loop:
169
175
  while h < input.length do
170
176
  # All non-basic code points < n have been
171
- # handled already. Find the next larger one:
177
+ # handled already. Find the next larger one:
172
178
 
173
179
  m = MAXINT
174
-
180
+
175
181
  input.each do |char|
176
182
  m = char if char >= n && char < m
177
183
  end
178
184
 
179
185
  # Increase delta enough to advance the decoder's
180
- # <n,i> state to <m,0>, but guard against overflow:
186
+ # <n,i> state to <m,0>, but guard against overflow:
181
187
 
182
- raise(RangeError, "punycode_overflow (1)") if m - n > ((MAXINT - delta) / (h + 1)).floor
188
+ raise(ConversionError, "punycode_overflow (1)") if m - n > ((MAXINT - delta) / (h + 1)).floor
183
189
 
184
190
  delta += (m - n) * (h + 1)
185
191
  n = m
@@ -187,11 +193,11 @@ module SimpleIDN
187
193
  input.each_with_index do |char, j|
188
194
  if char < n
189
195
  delta += 1
190
- raise(StandardError,"punycode_overflow(2)") if delta > MAXINT
196
+ raise(ConversionError, "punycode_overflow(2)") if delta > MAXINT
191
197
  end
192
198
 
193
199
  if (char == n)
194
- # Represent delta as a generalized variable-length integer:
200
+ # Represent delta as a generalized variable-length integer:
195
201
  q = delta
196
202
  k = BASE
197
203
  while true do
@@ -215,13 +221,13 @@ module SimpleIDN
215
221
  end
216
222
 
217
223
  end
218
-
224
+
219
225
  module_function
220
-
226
+
221
227
  # Converts a UTF-8 unicode string to a punycode ACE string.
222
228
  # == Example
223
229
  # SimpleIDN.to_ascii("møllerriis.com")
224
- # => "xn--mllerriis-l8a.com"
230
+ # => "xn--mllerriis-l8a.com"
225
231
  def to_ascii(domain)
226
232
  domain_array = domain.split(".") rescue []
227
233
  return domain if domain_array.length == 0
@@ -238,7 +244,7 @@ module SimpleIDN
238
244
  # Converts a punycode ACE string to a UTF-8 unicode string.
239
245
  # == Example
240
246
  # SimpleIDN.to_unicode("xn--mllerriis-l8a.com")
241
- # => "møllerriis.com"
247
+ # => "møllerriis.com"
242
248
  def to_unicode(domain)
243
249
  domain_array = domain.split(".") rescue []
244
250
  return domain if domain_array.length == 0
data/simpleidn.gemspec CHANGED
@@ -1,22 +1,23 @@
1
- # -*- encoding: utf-8 -*-
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'simpleidn'
2
5
 
3
- Gem::Specification.new do |s|
4
- s.name = "simpleidn"
5
- s.version = "0.0.5"
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "simpleidn"
8
+ spec.version = SimpleIDN::VERSION
9
+ spec.authors = ["Morten Møller Riis"]
10
+ spec.email = ["mortenmoellerriis _AT_ gmail.com"]
6
11
 
7
- s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
- s.authors = ["Morten M\u{f8}ller Riis"]
9
- s.cert_chain = ["/Users/mmr/gem-public_cert.pem"]
10
- s.date = "2013-11-22"
11
- s.description = "This gem allows easy conversion from punycode ACE strings to unicode UTF-8 strings and visa versa."
12
- s.email = "mortenmoellerriis _AT_ gmail.com"
13
- s.extra_rdoc_files = ["README.rdoc", "lib/simpleidn.rb"]
14
- s.files = ["LICENCE", "Manifest", "README.rdoc", "Rakefile", "lib/simpleidn.rb", "simpleidn.gemspec", "spec/idn.rb", "spec/test_vectors.rb"]
15
- s.homepage = "http://github.com/mmriis/simpleidn"
16
- s.rdoc_options = ["--line-numbers", "--title", "Simpleidn", "--main", "README.rdoc"]
17
- s.require_paths = ["lib"]
18
- s.rubyforge_project = "simpleidn"
19
- s.rubygems_version = "2.0.3"
20
- s.signing_key = "/Users/mmr/gem-private_key.pem"
21
- s.summary = "This gem allows easy conversion from punycode ACE strings to unicode UTF-8 strings and visa versa."
12
+ spec.summary = %q{Punycode ACE to unicode UTF-8 (and vice-versa) string conversion.}
13
+ spec.description = %q{This gem allows easy conversion from punycode ACE strings to unicode UTF-8 strings and vice-versa.}
14
+ spec.homepage = "https://github.com/mmriis/simpleidn"
15
+ spec.license = "MIT"
16
+
17
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_development_dependency "bundler", "~> 1.11"
21
+ spec.add_development_dependency "rake", "~> 10.0"
22
+ spec.add_development_dependency "rspec", "~> 3.0"
22
23
  end
metadata CHANGED
@@ -1,80 +1,94 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: simpleidn
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Morten Møller Riis
8
8
  autorequire:
9
9
  bindir: bin
10
- cert_chain:
11
- - |
12
- -----BEGIN CERTIFICATE-----
13
- MIIDRDCCAiygAwIBAgIBATANBgkqhkiG9w0BAQUFADBIMRowGAYDVQQDDBFtb3J0
14
- ZW5tb2VsbGVycmlpczEVMBMGCgmSJomT8ixkARkWBWdtYWlsMRMwEQYKCZImiZPy
15
- LGQBGRYDY29tMB4XDTEzMDQyMzA3MTMyMFoXDTE0MDQyMzA3MTMyMFowSDEaMBgG
16
- A1UEAwwRbW9ydGVubW9lbGxlcnJpaXMxFTATBgoJkiaJk/IsZAEZFgVnbWFpbDET
17
- MBEGCgmSJomT8ixkARkWA2NvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCCAQoC
18
- ggEBAKtTB3aT+LG2jPkb7hfGKTpyizK6MdOZmnt2xv3dlfA+aPnpliY3QccdJE3R
19
- d9nNHOaQ1rrCuhBBpZu/q7nuGD8ZuMxPcqYriBzfeUv2Nsgc2XXKp9E0UIpkuxf2
20
- Xkv26iWI7sYDzS0pCtu2of6Zw9GyVDVmB8Zf/xYQjDHDZZF6qNAVFTYvnAdl+qxb
21
- 1VQmOmzVszc33Ic9ZtJ896QjtBPUf82FIbEYz3uy75KwDfKHM4AS85wtWEFDL0Qt
22
- FXGlxmq3DkNKmTPrfQ/+i2Oy8JB+OdY9ZMDsOKS17LJh+CsadQNXrp1WvZgxgo/1
23
- HfsXb1m+lPZZIuN3WgKCDQMAxqECAwEAAaM5MDcwCQYDVR0TBAIwADALBgNVHQ8E
24
- BAMCBLAwHQYDVR0OBBYEFFhp4owxGE1Gv7NPEdw7gyx6YfozMA0GCSqGSIb3DQEB
25
- BQUAA4IBAQBy0sFmKseXn3IvWTA/FE/AibLwf0nuX9V7pJoCkOucxAyMilWn2XaG
26
- almQX9JlmoyHAcdQmRRd3O5QCPHu7wEwttlDlwYnNVu1QEGsF6qjCwtNQUkDKUjo
27
- kMsFfnKSBd9EmbGhivRVcgeiz835tol6Z5I8xI6ABvwdHEa/C2QFf8Pz+ZQC+pZF
28
- aKWJmlgFtTUWmXA2aYT802RYu2jikOyqaJze+sjolJ+nFpIud98txsKCDcV+idux
29
- 8FNpJsGlpnCc0gEItcONQYdrwnWmvfPIOMCnErdfQUo06P5qhoN32NrOZm+mZ3B9
30
- /yzabYiM9yPtlNlOoPX8Mgekm3mxAsI2
31
- -----END CERTIFICATE-----
32
- date: 2013-11-22 00:00:00.000000000 Z
33
- dependencies: []
10
+ cert_chain: []
11
+ date: 2016-02-15 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.11'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '3.0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '3.0'
34
55
  description: This gem allows easy conversion from punycode ACE strings to unicode
35
- UTF-8 strings and visa versa.
36
- email: mortenmoellerriis _AT_ gmail.com
56
+ UTF-8 strings and vice-versa.
57
+ email:
58
+ - mortenmoellerriis _AT_ gmail.com
37
59
  executables: []
38
60
  extensions: []
39
- extra_rdoc_files:
40
- - README.rdoc
41
- - lib/simpleidn.rb
61
+ extra_rdoc_files: []
42
62
  files:
63
+ - ".gitignore"
64
+ - Gemfile
43
65
  - LICENCE
44
- - Manifest
45
66
  - README.rdoc
46
67
  - Rakefile
47
68
  - lib/simpleidn.rb
48
69
  - simpleidn.gemspec
49
- - spec/idn.rb
50
- - spec/test_vectors.rb
51
- homepage: http://github.com/mmriis/simpleidn
52
- licenses: []
70
+ homepage: https://github.com/mmriis/simpleidn
71
+ licenses:
72
+ - MIT
53
73
  metadata: {}
54
74
  post_install_message:
55
- rdoc_options:
56
- - --line-numbers
57
- - --title
58
- - Simpleidn
59
- - --main
60
- - README.rdoc
75
+ rdoc_options: []
61
76
  require_paths:
62
77
  - lib
63
78
  required_ruby_version: !ruby/object:Gem::Requirement
64
79
  requirements:
65
- - - '>='
80
+ - - ">="
66
81
  - !ruby/object:Gem::Version
67
82
  version: '0'
68
83
  required_rubygems_version: !ruby/object:Gem::Requirement
69
84
  requirements:
70
- - - '>='
85
+ - - ">="
71
86
  - !ruby/object:Gem::Version
72
- version: '1.2'
87
+ version: '0'
73
88
  requirements: []
74
- rubyforge_project: simpleidn
75
- rubygems_version: 2.0.3
89
+ rubyforge_project:
90
+ rubygems_version: 2.4.5
76
91
  signing_key:
77
92
  specification_version: 4
78
- summary: This gem allows easy conversion from punycode ACE strings to unicode UTF-8
79
- strings and visa versa.
93
+ summary: Punycode ACE to unicode UTF-8 (and vice-versa) string conversion.
80
94
  test_files: []
checksums.yaml.gz.sig DELETED
Binary file
data.tar.gz.sig DELETED
@@ -1,2 +0,0 @@
1
- k��&�+*���p�� �A�������޸���˫ͅ�#
2
- �_�*`=
data/Manifest DELETED
@@ -1,8 +0,0 @@
1
- LICENCE
2
- Manifest
3
- README.rdoc
4
- Rakefile
5
- lib/simpleidn.rb
6
- simpleidn.gemspec
7
- spec/idn.rb
8
- spec/test_vectors.rb
data/spec/idn.rb DELETED
@@ -1,57 +0,0 @@
1
- # encoding: utf-8
2
- require 'rspec'
3
- require 'simpleidn'
4
- require 'test_vectors'
5
-
6
- describe "SimpleIDN" do
7
- describe "to_unicode" do
8
- it "should pass all test cases" do
9
- TESTCASES_JOSEFSSON.sort.each do |testcase, vector|
10
- SimpleIDN.to_unicode(vector[1]).should == vector[0]
11
- end
12
- end
13
-
14
- it "should respect * and not try to decode it" do
15
- SimpleIDN.to_unicode("*.xn--mllerriis-l8a.com").should == "*.møllerriis.com"
16
- end
17
-
18
- it "should respect leading _ and not try to encode it" do
19
- SimpleIDN.to_unicode("_something.xn--mllerriis-l8a.com").should == "_something.møllerriis.com"
20
- end
21
-
22
- it "should return nil for nil" do
23
- SimpleIDN.to_unicode(nil).should be_nil
24
- end
25
-
26
- it "should return . if only . given" do
27
- # https://github.com/mmriis/simpleidn/issues/3
28
- SimpleIDN.to_unicode('.').should == '.'
29
- end
30
-
31
- end
32
-
33
- describe "to_ascii" do
34
- it "should pass all test cases" do
35
- TESTCASES_JOSEFSSON.sort.each do |testcase, vector|
36
- SimpleIDN.to_ascii(vector[0]).should == vector[1].downcase
37
- end
38
- end
39
-
40
- it "should respect * and not try to encode it" do
41
- SimpleIDN.to_ascii("*.hello.com").should == "*.hello.com"
42
- end
43
-
44
- it "should respect leading _ and not try to encode it" do
45
- SimpleIDN.to_ascii("_something.example.org").should == "_something.example.org"
46
- end
47
-
48
- it "should return nil for nil" do
49
- SimpleIDN.to_ascii(nil).should be_nil
50
- end
51
-
52
- it "should return . if only . given" do
53
- # https://github.com/mmriis/simpleidn/issues/3
54
- SimpleIDN.to_ascii('.').should == '.'
55
- end
56
- end
57
- end
data/spec/test_vectors.rb DELETED
@@ -1,139 +0,0 @@
1
- # encoding: utf-8
2
- # JOSEFSSON test vectors, taken from DRAFT-JOSEFSSON-IDN-TEST-VECTORS-00:
3
- # http://www.gnu.org/software/libidn/draft-josefsson-idn-test-vectors.html
4
- #
5
- # Modifications:
6
- # - omission of 5.20 since it is identical with 5.8 (case H below)
7
-
8
- TESTCASES_JOSEFSSON = {
9
- 'A' => [
10
- [ 0x0644, 0x064A, 0x0647, 0x0645, 0x0627, 0x0628, 0x062A, 0x0643,
11
- 0x0644, 0x0645, 0x0648, 0x0634, 0x0639, 0x0631, 0x0628, 0x064A,
12
- 0x061F ].pack('U*'),
13
- 'xn--egbpdaj6bu4bxfgehfvwxn'
14
- ],
15
-
16
- 'B' => [
17
- [ 0x4ED6, 0x4EEC, 0x4E3A, 0x4EC0, 0x4E48, 0x4E0D, 0x8BF4, 0x4E2D,
18
- 0x6587 ].pack('U*'),
19
- 'xn--ihqwcrb4cv8a8dqg056pqjye'
20
- ],
21
-
22
- 'C' => [
23
- [ 0x4ED6, 0x5011, 0x7232, 0x4EC0, 0x9EBD, 0x4E0D, 0x8AAA, 0x4E2D,
24
- 0x6587 ].pack('U*'),
25
- 'xn--ihqwctvzc91f659drss3x8bo0yb'
26
- ],
27
-
28
- 'D' => [
29
- [ 0x0050, 0x0072, 0x006F, 0x010D, 0x0070, 0x0072, 0x006F, 0x0073,
30
- 0x0074, 0x011B, 0x006E, 0x0065, 0x006D, 0x006C, 0x0075, 0x0076,
31
- 0x00ED, 0x010D, 0x0065, 0x0073, 0x006B, 0x0079 ].pack('U*'),
32
- 'xn--Proprostnemluvesky-uyb24dma41a'
33
- ],
34
-
35
- 'E' => [
36
- [ 0x05DC, 0x05DE, 0x05D4, 0x05D4, 0x05DD, 0x05E4, 0x05E9, 0x05D5,
37
- 0x05D8, 0x05DC, 0x05D0, 0x05DE, 0x05D3, 0x05D1, 0x05E8, 0x05D9,
38
- 0x05DD, 0x05E2, 0x05D1, 0x05E8, 0x05D9, 0x05EA ].pack('U*'),
39
- 'xn--4dbcagdahymbxekheh6e0a7fei0b'
40
- ],
41
-
42
- 'F' => [
43
- [ 0x092F, 0x0939, 0x0932, 0x094B, 0x0917, 0x0939, 0x093F, 0x0928,
44
- 0x094D, 0x0926, 0x0940, 0x0915, 0x094D, 0x092F, 0x094B, 0x0902,
45
- 0x0928, 0x0939, 0x0940, 0x0902, 0x092C, 0x094B, 0x0932, 0x0938,
46
- 0x0915, 0x0924, 0x0947, 0x0939, 0x0948, 0x0902 ].pack('U*'),
47
- 'xn--i1baa7eci9glrd9b2ae1bj0hfcgg6iyaf8o0a1dig0cd'
48
- ],
49
-
50
- 'G' => [
51
- [ 0x306A, 0x305C, 0x307F, 0x3093, 0x306A, 0x65E5, 0x672C, 0x8A9E,
52
- 0x3092, 0x8A71, 0x3057, 0x3066, 0x304F, 0x308C, 0x306A, 0x3044,
53
- 0x306E, 0x304B ].pack('U*'),
54
- 'xn--n8jok5ay5dzabd5bym9f0cm5685rrjetr6pdxa'
55
- ],
56
-
57
- 'H' => [
58
- [ 0x043F, 0x043E, 0x0447, 0x0435, 0x043C, 0x0443, 0x0436, 0x0435,
59
- 0x043E, 0x043D, 0x0438, 0x043D, 0x0435, 0x0433, 0x043E, 0x0432,
60
- 0x043E, 0x0440, 0x044F, 0x0442, 0x043F, 0x043E, 0x0440, 0x0443,
61
- 0x0441, 0x0441, 0x043A, 0x0438 ].pack('U*'),
62
- 'xn--b1abfaaepdrnnbgefbadotcwatmq2g4l'
63
- ],
64
-
65
- 'I' => [
66
- [ 0x0050, 0x006F, 0x0072, 0x0071, 0x0075, 0x00E9, 0x006E, 0x006F,
67
- 0x0070, 0x0075, 0x0065, 0x0064, 0x0065, 0x006E, 0x0073, 0x0069,
68
- 0x006D, 0x0070, 0x006C, 0x0065, 0x006D, 0x0065, 0x006E, 0x0074,
69
- 0x0065, 0x0068, 0x0061, 0x0062, 0x006C, 0x0061, 0x0072, 0x0065,
70
- 0x006E, 0x0045, 0x0073, 0x0070, 0x0061, 0x00F1, 0x006F,
71
- 0x006C ].pack('U*'),
72
- 'xn--PorqunopuedensimplementehablarenEspaol-fmd56a'
73
- ],
74
-
75
- 'J' => [
76
- [ 0x0054, 0x1EA1, 0x0069, 0x0073, 0x0061, 0x006F, 0x0068, 0x1ECD,
77
- 0x006B, 0x0068, 0x00F4, 0x006E, 0x0067, 0x0074, 0x0068, 0x1EC3,
78
- 0x0063, 0x0068, 0x1EC9, 0x006E, 0x00F3, 0x0069, 0x0074, 0x0069,
79
- 0x1EBF, 0x006E, 0x0067, 0x0056, 0x0069, 0x1EC7, 0x0074 ].pack('U*'),
80
- 'xn--TisaohkhngthchnitingVit-kjcr8268qyxafd2f1b9g'
81
- ],
82
-
83
- 'K' => [
84
- [ 0x0033, 0x5E74, 0x0042, 0x7D44, 0x91D1, 0x516B, 0x5148,
85
- 0x751F ].pack('U*'),
86
- 'xn--3B-ww4c5e180e575a65lsy2b'
87
- ],
88
-
89
- 'L' => [
90
- [ 0x5B89, 0x5BA4, 0x5948, 0x7F8E, 0x6075, 0x002D, 0x0077, 0x0069,
91
- 0x0074, 0x0068, 0x002D, 0x0053, 0x0055, 0x0050, 0x0045, 0x0052,
92
- 0x002D, 0x004D, 0x004F, 0x004E, 0x004B, 0x0045, 0x0059,
93
- 0x0053 ].pack('U*'),
94
- 'xn---with-SUPER-MONKEYS-pc58ag80a8qai00g7n9n'
95
- ],
96
-
97
- 'M' => [
98
- [ 0x0048, 0x0065, 0x006C, 0x006C, 0x006F, 0x002D, 0x0041, 0x006E,
99
- 0x006F, 0x0074, 0x0068, 0x0065, 0x0072, 0x002D, 0x0057, 0x0061,
100
- 0x0079, 0x002D, 0x305D, 0x308C, 0x305E, 0x308C, 0x306E, 0x5834,
101
- 0x6240 ].pack('U*'),
102
- 'xn--Hello-Another-Way--fc4qua05auwb3674vfr0b'
103
- ],
104
-
105
- 'N' => [
106
- [ 0x3072, 0x3068, 0x3064, 0x5C4B, 0x6839, 0x306E, 0x4E0B,
107
- 0x0032 ].pack('U*'),
108
- 'xn--2-u9tlzr9756bt3uc0v'
109
- ],
110
-
111
- 'O' => [
112
- [ 0x004D, 0x0061, 0x006A, 0x0069, 0x3067, 0x004B, 0x006F, 0x0069,
113
- 0x3059, 0x308B, 0x0035, 0x79D2, 0x524D ].pack('U*'),
114
- 'xn--MajiKoi5-783gue6qz075azm5e'
115
- ],
116
-
117
- 'P' => [
118
- [ 0x30D1, 0x30D5, 0x30A3, 0x30FC, 0x0064, 0x0065, 0x30EB, 0x30F3,
119
- 0x30D0 ].pack('U*'),
120
- 'xn--de-jg4avhby1noc0d'
121
- ],
122
-
123
- 'Q' => [
124
- [ 0x305D, 0x306E, 0x30B9, 0x30D4, 0x30FC, 0x30C9, 0x3067 ].pack('U*'),
125
- 'xn--d9juau41awczczp'
126
- ],
127
-
128
- 'R' => [
129
- [ 0x03B5, 0x03BB, 0x03BB, 0x03B7, 0x03BD, 0x03B9, 0x03BA,
130
- 0x03AC ].pack('U*'),
131
- 'xn--hxargifdar'
132
- ],
133
-
134
- 'S' => [
135
- [ 0x0062, 0x006F, 0x006E, 0x0121, 0x0075, 0x0073, 0x0061, 0x0127,
136
- 0x0127, 0x0061 ].pack('U*'),
137
- 'xn--bonusaa-5bb1da'
138
- ]
139
- }
metadata.gz.sig DELETED
@@ -1 +0,0 @@
1
- t�fG��Ql���W���������O^� ��wC�'��|;��~c��̕��y���䏼����&j.Jk�~�Z� �E��t��cGif��_�$h0�V�͍���bQ�U�]݆��U��CD�ɓn�$�L*��3d�a��۩�&�=�� r>�H9��_4N��޹C�-��䐙��u˕T v�/�RTǖ�R�_��kQ�