addressable 2.6.0 → 2.8.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/CHANGELOG.md +64 -0
- data/Gemfile +14 -16
- data/README.md +12 -10
- data/Rakefile +14 -8
- data/addressable.gemspec +28 -0
- data/lib/addressable/idna/native.rb +8 -3
- data/lib/addressable/idna/pure.rb +20 -191
- data/lib/addressable/idna.rb +0 -1
- data/lib/addressable/template.rb +37 -53
- data/lib/addressable/uri.rb +257 -176
- data/lib/addressable/version.rb +2 -3
- data/spec/addressable/idna_spec.rb +9 -7
- data/spec/addressable/net_http_compat_spec.rb +0 -1
- data/spec/addressable/security_spec.rb +0 -1
- data/spec/addressable/template_spec.rb +78 -265
- data/spec/addressable/uri_spec.rb +503 -208
- data/spec/spec_helper.rb +9 -0
- data/tasks/gem.rake +9 -7
- data/tasks/profile.rake +72 -0
- data/tasks/rspec.rake +1 -1
- metadata +16 -15
- data/spec/addressable/rack_mount_compat_spec.rb +0 -106
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 5b7d4ea3b683b3b7c719ae54919505e8e98823b39e54cd68d3579319b61d9824
|
4
|
+
data.tar.gz: d09b61eba34544826aec64909b848b53549ae64059e09cc5f462991a59fd2465
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 37927e878581e256a98ac619723a90f7b7a2d5b655ef613872a4f963ffdccabc6f0b761b65673fc6929509b0f783b48460b2643ac33c2d076bc5234e4126573b
|
7
|
+
data.tar.gz: 3afd1d272e41f97959bc8b34188b8d9fc419fcc01af9ea8a955d3ee2e6f57e3417d5ec6c58378e6b29fedb15e948ace7c080cd2c3739d6e24a4dd04eb3fa3f70
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,67 @@
|
|
1
|
+
# Addressable 2.8.5
|
2
|
+
- Fix thread safety issue with encoding tables ([#515])
|
3
|
+
- Define URI::NONE as a module to avoid serialization issues ([#509])
|
4
|
+
- Fix YAML serialization ([#508])
|
5
|
+
|
6
|
+
[#508]: https://github.com/sporkmonger/addressable/pull/508
|
7
|
+
[#509]: https://github.com/sporkmonger/addressable/pull/509
|
8
|
+
[#515]: https://github.com/sporkmonger/addressable/pull/515
|
9
|
+
|
10
|
+
# Addressable 2.8.4
|
11
|
+
- Restore `Addressable::IDNA.unicode_normalize_kc` as a deprecated method ([#504])
|
12
|
+
|
13
|
+
[#504]: https://github.com/sporkmonger/addressable/pull/504
|
14
|
+
|
15
|
+
# Addressable 2.8.3
|
16
|
+
- Fix template expand level 2 hash support for non-string objects ([#499], [#498])
|
17
|
+
|
18
|
+
[#499]: https://github.com/sporkmonger/addressable/pull/499
|
19
|
+
[#498]: https://github.com/sporkmonger/addressable/pull/498
|
20
|
+
|
21
|
+
# Addressable 2.8.2
|
22
|
+
- Improve cache hits and JIT friendliness ([#486](https://github.com/sporkmonger/addressable/pull/486))
|
23
|
+
- Improve code style and test coverage ([#482](https://github.com/sporkmonger/addressable/pull/482))
|
24
|
+
- Ensure reset of deferred validation ([#481](https://github.com/sporkmonger/addressable/pull/481))
|
25
|
+
- Resolve normalization differences between `IDNA::Native` and `IDNA::Pure` ([#408](https://github.com/sporkmonger/addressable/issues/408), [#492])
|
26
|
+
- Remove redundant colon in `Addressable::URI::CharacterClasses::AUTHORITY` regex ([#438](https://github.com/sporkmonger/addressable/pull/438)) (accidentally reverted by [#449] merge but [added back](https://github.com/sporkmonger/addressable/pull/492#discussion_r1105125280) in [#492])
|
27
|
+
|
28
|
+
[#492]: https://github.com/sporkmonger/addressable/pull/492
|
29
|
+
|
30
|
+
# Addressable 2.8.1
|
31
|
+
- refactor `Addressable::URI.normalize_path` to address linter offenses ([#430](https://github.com/sporkmonger/addressable/pull/430))
|
32
|
+
- update gemspec to reflect supported Ruby versions ([#466], [#464], [#463])
|
33
|
+
- compatibility w/ public_suffix 5.x ([#466], [#465], [#460])
|
34
|
+
- fixes "invalid byte sequence in UTF-8" exception when unencoding URLs containing non UTF-8 characters ([#459](https://github.com/sporkmonger/addressable/pull/459))
|
35
|
+
- `Ractor` compatibility ([#449])
|
36
|
+
- use the whole string instead of a single line for template match ([#431](https://github.com/sporkmonger/addressable/pull/431))
|
37
|
+
- force UTF-8 encoding only if needed ([#341](https://github.com/sporkmonger/addressable/pull/341))
|
38
|
+
|
39
|
+
[#449]: https://github.com/sporkmonger/addressable/pull/449
|
40
|
+
[#460]: https://github.com/sporkmonger/addressable/pull/460
|
41
|
+
[#463]: https://github.com/sporkmonger/addressable/pull/463
|
42
|
+
[#464]: https://github.com/sporkmonger/addressable/pull/464
|
43
|
+
[#465]: https://github.com/sporkmonger/addressable/pull/465
|
44
|
+
[#466]: https://github.com/sporkmonger/addressable/pull/466
|
45
|
+
|
46
|
+
# Addressable 2.8.0
|
47
|
+
- fixes ReDoS vulnerability in Addressable::Template#match
|
48
|
+
- no longer replaces `+` with spaces in queries for non-http(s) schemes
|
49
|
+
- fixed encoding ipv6 literals
|
50
|
+
- the `:compacted` flag for `normalized_query` now dedupes parameters
|
51
|
+
- fix broken `escape_component` alias
|
52
|
+
- dropping support for Ruby 2.0 and 2.1
|
53
|
+
- adding Ruby 3.0 compatibility for development tasks
|
54
|
+
- drop support for `rack-mount` and remove Addressable::Template#generate
|
55
|
+
- performance improvements
|
56
|
+
- switch CI/CD to GitHub Actions
|
57
|
+
|
58
|
+
# Addressable 2.7.0
|
59
|
+
- added `:compacted` flag to `normalized_query`
|
60
|
+
- `heuristic_parse` handles `mailto:` more intuitively
|
61
|
+
- dropped explicit support for JRuby 9.0.5.0
|
62
|
+
- compatibility w/ public_suffix 4.x
|
63
|
+
- performance improvements
|
64
|
+
|
1
65
|
# Addressable 2.6.0
|
2
66
|
- added `tld=` method to allow assignment to the public suffix
|
3
67
|
- most `heuristic_parse` patterns are now case-insensitive
|
data/Gemfile
CHANGED
@@ -1,10 +1,17 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
gemspec
|
4
6
|
|
5
7
|
group :test do
|
6
|
-
gem 'rspec', '~> 3.
|
7
|
-
gem 'rspec-its', '~> 1.
|
8
|
+
gem 'rspec', '~> 3.8'
|
9
|
+
gem 'rspec-its', '~> 1.3'
|
10
|
+
end
|
11
|
+
|
12
|
+
group :coverage do
|
13
|
+
gem "coveralls", "> 0.7", require: false, platforms: :mri
|
14
|
+
gem "simplecov", require: false
|
8
15
|
end
|
9
16
|
|
10
17
|
group :development do
|
@@ -14,19 +21,10 @@ group :development do
|
|
14
21
|
end
|
15
22
|
|
16
23
|
group :test, :development do
|
17
|
-
gem '
|
18
|
-
gem
|
19
|
-
gem 'coveralls', :require => false, :platforms => [
|
20
|
-
:ruby_20, :ruby_21, :ruby_22, :ruby_23
|
21
|
-
]
|
22
|
-
# Used to test compatibility.
|
23
|
-
gem 'rack-mount', git: 'https://github.com/sporkmonger/rack-mount.git', require: 'rack/mount'
|
24
|
-
|
25
|
-
if RUBY_VERSION.start_with?('2.0', '2.1')
|
26
|
-
gem 'rack', '< 2', :require => false
|
27
|
-
else
|
28
|
-
gem 'rack', :require => false
|
29
|
-
end
|
24
|
+
gem 'memory_profiler'
|
25
|
+
gem "rake", ">= 12.3.3"
|
30
26
|
end
|
31
27
|
|
32
|
-
|
28
|
+
unless ENV["IDNA_MODE"] == "pure"
|
29
|
+
gem "idn-ruby", platform: :mri
|
30
|
+
end
|
data/README.md
CHANGED
@@ -7,21 +7,23 @@
|
|
7
7
|
<dt>License</dt><dd>Apache 2.0</dd>
|
8
8
|
</dl>
|
9
9
|
|
10
|
-
[![Gem Version](
|
11
|
-
[![Build Status](https://
|
10
|
+
[![Gem Version](https://img.shields.io/gem/dt/addressable.svg)][gem]
|
11
|
+
[![Build Status](https://github.com/sporkmonger/addressable/workflows/CI/badge.svg)][actions]
|
12
12
|
[![Test Coverage Status](https://img.shields.io/coveralls/sporkmonger/addressable.svg)][coveralls]
|
13
|
-
[![Documentation Coverage Status](
|
13
|
+
[![Documentation Coverage Status](https://inch-ci.org/github/sporkmonger/addressable.svg?branch=master)][inch]
|
14
14
|
|
15
15
|
[gem]: https://rubygems.org/gems/addressable
|
16
|
-
[
|
16
|
+
[actions]: https://github.com/sporkmonger/addressable/actions
|
17
17
|
[coveralls]: https://coveralls.io/r/sporkmonger/addressable
|
18
|
-
[inch]:
|
18
|
+
[inch]: https://inch-ci.org/github/sporkmonger/addressable
|
19
19
|
|
20
20
|
# Description
|
21
21
|
|
22
|
-
Addressable is
|
23
|
-
Ruby's standard library. It
|
24
|
-
|
22
|
+
Addressable is an alternative implementation to the URI implementation
|
23
|
+
that is part of Ruby's standard library. It is flexible, offers heuristic
|
24
|
+
parsing, and additionally provides extensive support for IRIs and URI templates.
|
25
|
+
|
26
|
+
Addressable closely conforms to RFC 3986, RFC 3987, and RFC 6570 (level 4).
|
25
27
|
|
26
28
|
# Reference
|
27
29
|
|
@@ -96,7 +98,7 @@ You may optionally turn on native IDN support by installing libidn and the
|
|
96
98
|
idn gem:
|
97
99
|
|
98
100
|
```console
|
99
|
-
$ sudo apt-get install
|
101
|
+
$ sudo apt-get install libidn11-dev # Debian/Ubuntu
|
100
102
|
$ brew install libidn # OS X
|
101
103
|
$ gem install idn-ruby
|
102
104
|
```
|
@@ -108,7 +110,7 @@ dependency using a pessimistic version constraint covering the major and minor
|
|
108
110
|
values:
|
109
111
|
|
110
112
|
```ruby
|
111
|
-
spec.add_dependency 'addressable', '~> 2.
|
113
|
+
spec.add_dependency 'addressable', '~> 2.7'
|
112
114
|
```
|
113
115
|
|
114
116
|
If you need a specific bug fix, you can also specify minimum tiny versions
|
data/Rakefile
CHANGED
@@ -14,17 +14,23 @@ RELEASE_NAME = "REL #{PKG_VERSION}"
|
|
14
14
|
|
15
15
|
PKG_SUMMARY = "URI Implementation"
|
16
16
|
PKG_DESCRIPTION = <<-TEXT
|
17
|
-
Addressable is
|
18
|
-
Ruby's standard library. It
|
19
|
-
|
17
|
+
Addressable is an alternative implementation to the URI implementation that is
|
18
|
+
part of Ruby's standard library. It is flexible, offers heuristic parsing, and
|
19
|
+
additionally provides extensive support for IRIs and URI templates.
|
20
20
|
TEXT
|
21
21
|
|
22
22
|
PKG_FILES = FileList[
|
23
|
-
"
|
24
|
-
"
|
25
|
-
"
|
26
|
-
|
27
|
-
|
23
|
+
"data/**/*",
|
24
|
+
"lib/**/*.rb",
|
25
|
+
"spec/**/*.rb",
|
26
|
+
"tasks/**/*.rake",
|
27
|
+
"addressable.gemspec",
|
28
|
+
"CHANGELOG.md",
|
29
|
+
"Gemfile",
|
30
|
+
"LICENSE.txt",
|
31
|
+
"README.md",
|
32
|
+
"Rakefile",
|
33
|
+
]
|
28
34
|
|
29
35
|
task :default => "spec"
|
30
36
|
|
data/addressable.gemspec
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
# stub: addressable 2.8.5 ruby lib
|
3
|
+
|
4
|
+
Gem::Specification.new do |s|
|
5
|
+
s.name = "addressable".freeze
|
6
|
+
s.version = "2.8.5"
|
7
|
+
|
8
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
9
|
+
s.metadata = { "changelog_uri" => "https://github.com/sporkmonger/addressable/blob/main/CHANGELOG.md" } if s.respond_to? :metadata=
|
10
|
+
s.require_paths = ["lib".freeze]
|
11
|
+
s.authors = ["Bob Aman".freeze]
|
12
|
+
s.date = "2023-08-03"
|
13
|
+
s.description = "Addressable is an alternative implementation to the URI implementation that is\npart of Ruby's standard library. It is flexible, offers heuristic parsing, and\nadditionally provides extensive support for IRIs and URI templates.\n".freeze
|
14
|
+
s.email = "bob@sporkmonger.com".freeze
|
15
|
+
s.extra_rdoc_files = ["README.md".freeze]
|
16
|
+
s.files = ["CHANGELOG.md".freeze, "Gemfile".freeze, "LICENSE.txt".freeze, "README.md".freeze, "Rakefile".freeze, "addressable.gemspec".freeze, "data/unicode.data".freeze, "lib/addressable.rb".freeze, "lib/addressable/idna.rb".freeze, "lib/addressable/idna/native.rb".freeze, "lib/addressable/idna/pure.rb".freeze, "lib/addressable/template.rb".freeze, "lib/addressable/uri.rb".freeze, "lib/addressable/version.rb".freeze, "spec/addressable/idna_spec.rb".freeze, "spec/addressable/net_http_compat_spec.rb".freeze, "spec/addressable/security_spec.rb".freeze, "spec/addressable/template_spec.rb".freeze, "spec/addressable/uri_spec.rb".freeze, "spec/spec_helper.rb".freeze, "tasks/clobber.rake".freeze, "tasks/gem.rake".freeze, "tasks/git.rake".freeze, "tasks/metrics.rake".freeze, "tasks/profile.rake".freeze, "tasks/rspec.rake".freeze, "tasks/yard.rake".freeze]
|
17
|
+
s.homepage = "https://github.com/sporkmonger/addressable".freeze
|
18
|
+
s.licenses = ["Apache-2.0".freeze]
|
19
|
+
s.rdoc_options = ["--main".freeze, "README.md".freeze]
|
20
|
+
s.required_ruby_version = Gem::Requirement.new(">= 2.2".freeze)
|
21
|
+
s.rubygems_version = "3.4.18".freeze
|
22
|
+
s.summary = "URI Implementation".freeze
|
23
|
+
|
24
|
+
s.specification_version = 4
|
25
|
+
|
26
|
+
s.add_runtime_dependency(%q<public_suffix>.freeze, [">= 2.0.2", "< 6.0"])
|
27
|
+
s.add_development_dependency(%q<bundler>.freeze, [">= 1.0", "< 3.0"])
|
28
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# encoding:utf-8
|
4
3
|
#--
|
5
4
|
# Copyright (C) Bob Aman
|
6
5
|
#
|
@@ -30,8 +29,14 @@ module Addressable
|
|
30
29
|
IDN::Punycode.decode(value.to_s)
|
31
30
|
end
|
32
31
|
|
33
|
-
|
34
|
-
|
32
|
+
class << self
|
33
|
+
# @deprecated Use {String#unicode_normalize(:nfkc)} instead
|
34
|
+
def unicode_normalize_kc(value)
|
35
|
+
value.to_s.unicode_normalize(:nfkc)
|
36
|
+
end
|
37
|
+
|
38
|
+
extend Gem::Deprecate
|
39
|
+
deprecate :unicode_normalize_kc, "String#unicode_normalize(:nfkc)", 2023, 4
|
35
40
|
end
|
36
41
|
|
37
42
|
def self.to_ascii(value)
|
@@ -1,6 +1,5 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
# encoding:utf-8
|
4
3
|
#--
|
5
4
|
# Copyright (C) Bob Aman
|
6
5
|
#
|
@@ -67,7 +66,7 @@ module Addressable
|
|
67
66
|
# domain name as described in RFC 3490.
|
68
67
|
def self.to_ascii(input)
|
69
68
|
input = input.to_s unless input.is_a?(String)
|
70
|
-
input = input.dup
|
69
|
+
input = input.dup.force_encoding(Encoding::UTF_8).unicode_normalize(:nfkc)
|
71
70
|
if input.respond_to?(:force_encoding)
|
72
71
|
input.force_encoding(Encoding::ASCII_8BIT)
|
73
72
|
end
|
@@ -78,7 +77,7 @@ module Addressable
|
|
78
77
|
part.force_encoding(Encoding::ASCII_8BIT)
|
79
78
|
end
|
80
79
|
if part =~ UTF8_REGEX && part =~ UTF8_REGEX_MULTIBYTE
|
81
|
-
ACE_PREFIX + punycode_encode(
|
80
|
+
ACE_PREFIX + punycode_encode(part)
|
82
81
|
else
|
83
82
|
part
|
84
83
|
end
|
@@ -113,13 +112,14 @@ module Addressable
|
|
113
112
|
output
|
114
113
|
end
|
115
114
|
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
115
|
+
class << self
|
116
|
+
# @deprecated Use {String#unicode_normalize(:nfkc)} instead
|
117
|
+
def unicode_normalize_kc(value)
|
118
|
+
value.to_s.unicode_normalize(:nfkc)
|
119
|
+
end
|
120
|
+
|
121
|
+
extend Gem::Deprecate
|
122
|
+
deprecate :unicode_normalize_kc, "String#unicode_normalize(:nfkc)", 2023, 4
|
123
123
|
end
|
124
124
|
|
125
125
|
##
|
@@ -135,163 +135,7 @@ module Addressable
|
|
135
135
|
unpacked.map! { |codepoint| lookup_unicode_lowercase(codepoint) }
|
136
136
|
return unpacked.pack("U*")
|
137
137
|
end
|
138
|
-
|
139
|
-
|
140
|
-
def self.unicode_compose(unpacked)
|
141
|
-
unpacked_result = []
|
142
|
-
length = unpacked.length
|
143
|
-
|
144
|
-
return unpacked if length == 0
|
145
|
-
|
146
|
-
starter = unpacked[0]
|
147
|
-
starter_cc = lookup_unicode_combining_class(starter)
|
148
|
-
starter_cc = 256 if starter_cc != 0
|
149
|
-
for i in 1...length
|
150
|
-
ch = unpacked[i]
|
151
|
-
|
152
|
-
if (starter_cc == 0 &&
|
153
|
-
(composite = unicode_compose_pair(starter, ch)) != nil)
|
154
|
-
starter = composite
|
155
|
-
else
|
156
|
-
unpacked_result << starter
|
157
|
-
starter = ch
|
158
|
-
end
|
159
|
-
end
|
160
|
-
unpacked_result << starter
|
161
|
-
return unpacked_result
|
162
|
-
end
|
163
|
-
(class <<self; private :unicode_compose; end)
|
164
|
-
|
165
|
-
def self.unicode_compose_pair(ch_one, ch_two)
|
166
|
-
if ch_one >= HANGUL_LBASE && ch_one < HANGUL_LBASE + HANGUL_LCOUNT &&
|
167
|
-
ch_two >= HANGUL_VBASE && ch_two < HANGUL_VBASE + HANGUL_VCOUNT
|
168
|
-
# Hangul L + V
|
169
|
-
return HANGUL_SBASE + (
|
170
|
-
(ch_one - HANGUL_LBASE) * HANGUL_VCOUNT + (ch_two - HANGUL_VBASE)
|
171
|
-
) * HANGUL_TCOUNT
|
172
|
-
elsif ch_one >= HANGUL_SBASE &&
|
173
|
-
ch_one < HANGUL_SBASE + HANGUL_SCOUNT &&
|
174
|
-
(ch_one - HANGUL_SBASE) % HANGUL_TCOUNT == 0 &&
|
175
|
-
ch_two >= HANGUL_TBASE && ch_two < HANGUL_TBASE + HANGUL_TCOUNT
|
176
|
-
# Hangul LV + T
|
177
|
-
return ch_one + (ch_two - HANGUL_TBASE)
|
178
|
-
end
|
179
|
-
|
180
|
-
p = []
|
181
|
-
ucs4_to_utf8 = lambda do |ch|
|
182
|
-
if ch < 128
|
183
|
-
p << ch
|
184
|
-
elsif ch < 2048
|
185
|
-
p << (ch >> 6 | 192)
|
186
|
-
p << (ch & 63 | 128)
|
187
|
-
elsif ch < 0x10000
|
188
|
-
p << (ch >> 12 | 224)
|
189
|
-
p << (ch >> 6 & 63 | 128)
|
190
|
-
p << (ch & 63 | 128)
|
191
|
-
elsif ch < 0x200000
|
192
|
-
p << (ch >> 18 | 240)
|
193
|
-
p << (ch >> 12 & 63 | 128)
|
194
|
-
p << (ch >> 6 & 63 | 128)
|
195
|
-
p << (ch & 63 | 128)
|
196
|
-
elsif ch < 0x4000000
|
197
|
-
p << (ch >> 24 | 248)
|
198
|
-
p << (ch >> 18 & 63 | 128)
|
199
|
-
p << (ch >> 12 & 63 | 128)
|
200
|
-
p << (ch >> 6 & 63 | 128)
|
201
|
-
p << (ch & 63 | 128)
|
202
|
-
elsif ch < 0x80000000
|
203
|
-
p << (ch >> 30 | 252)
|
204
|
-
p << (ch >> 24 & 63 | 128)
|
205
|
-
p << (ch >> 18 & 63 | 128)
|
206
|
-
p << (ch >> 12 & 63 | 128)
|
207
|
-
p << (ch >> 6 & 63 | 128)
|
208
|
-
p << (ch & 63 | 128)
|
209
|
-
end
|
210
|
-
end
|
211
|
-
|
212
|
-
ucs4_to_utf8.call(ch_one)
|
213
|
-
ucs4_to_utf8.call(ch_two)
|
214
|
-
|
215
|
-
return lookup_unicode_composition(p)
|
216
|
-
end
|
217
|
-
(class <<self; private :unicode_compose_pair; end)
|
218
|
-
|
219
|
-
def self.unicode_sort_canonical(unpacked)
|
220
|
-
unpacked = unpacked.dup
|
221
|
-
i = 1
|
222
|
-
length = unpacked.length
|
223
|
-
|
224
|
-
return unpacked if length < 2
|
225
|
-
|
226
|
-
while i < length
|
227
|
-
last = unpacked[i-1]
|
228
|
-
ch = unpacked[i]
|
229
|
-
last_cc = lookup_unicode_combining_class(last)
|
230
|
-
cc = lookup_unicode_combining_class(ch)
|
231
|
-
if cc != 0 && last_cc != 0 && last_cc > cc
|
232
|
-
unpacked[i] = last
|
233
|
-
unpacked[i-1] = ch
|
234
|
-
i -= 1 if i > 1
|
235
|
-
else
|
236
|
-
i += 1
|
237
|
-
end
|
238
|
-
end
|
239
|
-
return unpacked
|
240
|
-
end
|
241
|
-
(class <<self; private :unicode_sort_canonical; end)
|
242
|
-
|
243
|
-
def self.unicode_decompose(unpacked)
|
244
|
-
unpacked_result = []
|
245
|
-
for cp in unpacked
|
246
|
-
if cp >= HANGUL_SBASE && cp < HANGUL_SBASE + HANGUL_SCOUNT
|
247
|
-
l, v, t = unicode_decompose_hangul(cp)
|
248
|
-
unpacked_result << l
|
249
|
-
unpacked_result << v if v
|
250
|
-
unpacked_result << t if t
|
251
|
-
else
|
252
|
-
dc = lookup_unicode_compatibility(cp)
|
253
|
-
unless dc
|
254
|
-
unpacked_result << cp
|
255
|
-
else
|
256
|
-
unpacked_result.concat(unicode_decompose(dc.unpack("U*")))
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
260
|
-
return unpacked_result
|
261
|
-
end
|
262
|
-
(class <<self; private :unicode_decompose; end)
|
263
|
-
|
264
|
-
def self.unicode_decompose_hangul(codepoint)
|
265
|
-
sindex = codepoint - HANGUL_SBASE;
|
266
|
-
if sindex < 0 || sindex >= HANGUL_SCOUNT
|
267
|
-
l = codepoint
|
268
|
-
v = t = nil
|
269
|
-
return l, v, t
|
270
|
-
end
|
271
|
-
l = HANGUL_LBASE + sindex / HANGUL_NCOUNT
|
272
|
-
v = HANGUL_VBASE + (sindex % HANGUL_NCOUNT) / HANGUL_TCOUNT
|
273
|
-
t = HANGUL_TBASE + sindex % HANGUL_TCOUNT
|
274
|
-
if t == HANGUL_TBASE
|
275
|
-
t = nil
|
276
|
-
end
|
277
|
-
return l, v, t
|
278
|
-
end
|
279
|
-
(class <<self; private :unicode_decompose_hangul; end)
|
280
|
-
|
281
|
-
def self.lookup_unicode_combining_class(codepoint)
|
282
|
-
codepoint_data = UNICODE_DATA[codepoint]
|
283
|
-
(codepoint_data ?
|
284
|
-
(codepoint_data[UNICODE_DATA_COMBINING_CLASS] || 0) :
|
285
|
-
0)
|
286
|
-
end
|
287
|
-
(class <<self; private :lookup_unicode_combining_class; end)
|
288
|
-
|
289
|
-
def self.lookup_unicode_compatibility(codepoint)
|
290
|
-
codepoint_data = UNICODE_DATA[codepoint]
|
291
|
-
(codepoint_data ?
|
292
|
-
codepoint_data[UNICODE_DATA_COMPATIBILITY] : nil)
|
293
|
-
end
|
294
|
-
(class <<self; private :lookup_unicode_compatibility; end)
|
138
|
+
private_class_method :unicode_downcase
|
295
139
|
|
296
140
|
def self.lookup_unicode_lowercase(codepoint)
|
297
141
|
codepoint_data = UNICODE_DATA[codepoint]
|
@@ -299,22 +143,7 @@ module Addressable
|
|
299
143
|
(codepoint_data[UNICODE_DATA_LOWERCASE] || codepoint) :
|
300
144
|
codepoint)
|
301
145
|
end
|
302
|
-
|
303
|
-
|
304
|
-
def self.lookup_unicode_composition(unpacked)
|
305
|
-
return COMPOSITION_TABLE[unpacked]
|
306
|
-
end
|
307
|
-
(class <<self; private :lookup_unicode_composition; end)
|
308
|
-
|
309
|
-
HANGUL_SBASE = 0xac00
|
310
|
-
HANGUL_LBASE = 0x1100
|
311
|
-
HANGUL_LCOUNT = 19
|
312
|
-
HANGUL_VBASE = 0x1161
|
313
|
-
HANGUL_VCOUNT = 21
|
314
|
-
HANGUL_TBASE = 0x11a7
|
315
|
-
HANGUL_TCOUNT = 28
|
316
|
-
HANGUL_NCOUNT = HANGUL_VCOUNT * HANGUL_TCOUNT # 588
|
317
|
-
HANGUL_SCOUNT = HANGUL_LCOUNT * HANGUL_NCOUNT # 11172
|
146
|
+
private_class_method :lookup_unicode_lowercase
|
318
147
|
|
319
148
|
UNICODE_DATA_COMBINING_CLASS = 0
|
320
149
|
UNICODE_DATA_EXCLUSION = 1
|
@@ -341,7 +170,7 @@ module Addressable
|
|
341
170
|
end
|
342
171
|
|
343
172
|
COMPOSITION_TABLE = {}
|
344
|
-
|
173
|
+
UNICODE_DATA.each do |codepoint, data|
|
345
174
|
canonical = data[UNICODE_DATA_CANONICAL]
|
346
175
|
exclusion = data[UNICODE_DATA_EXCLUSION]
|
347
176
|
|
@@ -500,7 +329,7 @@ module Addressable
|
|
500
329
|
|
501
330
|
output[0..outlen].map { |x| x.chr }.join("").sub(/\0+\z/, "")
|
502
331
|
end
|
503
|
-
|
332
|
+
private_class_method :punycode_encode
|
504
333
|
|
505
334
|
def self.punycode_decode(punycode)
|
506
335
|
input = []
|
@@ -622,22 +451,22 @@ module Addressable
|
|
622
451
|
|
623
452
|
output.pack("U*")
|
624
453
|
end
|
625
|
-
|
454
|
+
private_class_method :punycode_decode
|
626
455
|
|
627
456
|
def self.punycode_basic?(codepoint)
|
628
457
|
codepoint < 0x80
|
629
458
|
end
|
630
|
-
|
459
|
+
private_class_method :punycode_basic?
|
631
460
|
|
632
461
|
def self.punycode_delimiter?(codepoint)
|
633
462
|
codepoint == PUNYCODE_DELIMITER
|
634
463
|
end
|
635
|
-
|
464
|
+
private_class_method :punycode_delimiter?
|
636
465
|
|
637
466
|
def self.punycode_encode_digit(d)
|
638
467
|
d + 22 + 75 * ((d < 26) ? 1 : 0)
|
639
468
|
end
|
640
|
-
|
469
|
+
private_class_method :punycode_encode_digit
|
641
470
|
|
642
471
|
# Returns the numeric value of a basic codepoint
|
643
472
|
# (for use in representing integers) in the range 0 to
|
@@ -653,7 +482,7 @@ module Addressable
|
|
653
482
|
PUNYCODE_BASE
|
654
483
|
end
|
655
484
|
end
|
656
|
-
|
485
|
+
private_class_method :punycode_decode_digit
|
657
486
|
|
658
487
|
# Bias adaptation method
|
659
488
|
def self.punycode_adapt(delta, numpoints, firsttime)
|
@@ -670,7 +499,7 @@ module Addressable
|
|
670
499
|
|
671
500
|
k + (difference + 1) * delta / (delta + PUNYCODE_SKEW)
|
672
501
|
end
|
673
|
-
|
502
|
+
private_class_method :punycode_adapt
|
674
503
|
end
|
675
504
|
# :startdoc:
|
676
505
|
end
|