uri-idna 0.2.1 → 0.3.0

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 90b0f85ec0c8f446c31e27d21bbec12432dd8420dad9cc832b49db7841b524fe
4
- data.tar.gz: d82a9c301f37b391852206bc5fe82b01f2fc71750743a5e5309bdf9dd5b48f49
3
+ metadata.gz: e0be96c995cea54b44d066d20834e442c4f228ddaeccfb47288c61ebcc35f120
4
+ data.tar.gz: 366f2c3f1c9e20e9ad5bd65b61a4c8a6bda1612d35f30089858424dcdc2af3a3
5
5
  SHA512:
6
- metadata.gz: e6d00f5c92cc2413b6fc7c4d36e1ee94fd6ede4e4dba1e01d934313811ac5483226637d0c70d200a037448fc84b8445c6ecdd599000ff56647f7077c0cc0ab2e
7
- data.tar.gz: 7281c010c9134b72d4f6d63014143dce1f8864ff3beb1fa53ab6e2103acc44a46ca4ba5677679435a16b18b680ccdbf9a4fe1bb06f313f12bcfcc677dbfbaec0
6
+ metadata.gz: 90bf436ab38aee10300a5d3f0ccc9700884ce7b98f99552cf9092f3b60224e75c79d7fb611e3791bdd9965b74717fef8e1425efcebbee0ee21dff5987bf2201f
7
+ data.tar.gz: 4e03e4bbf53ae6f2f1349efef8fed20869d2dd3f9b3af1a4e15e826899ed0ea58be2803ab866ce83bdc34198bdba184ef5c27aa19b3b4e3dd2547d3850d6cb8f
data/CHANGELOG.md CHANGED
@@ -7,6 +7,19 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [0.3.0] - 2025-05-09
11
+
12
+ ### Fixed
13
+
14
+ - Allow empty labels in UTS46 and WHATWG. ([@skryukov])
15
+ - Update comment in data-files to mention rake command. ([@skryukov])
16
+
17
+ ## [0.2.2] - 2023-11-25
18
+
19
+ ### Changed
20
+
21
+ - Internal implementation moved to regex-based algorithm to improve performance. ([@skryukov])
22
+
10
23
  ## [0.2.1] - 2023-11-15
11
24
 
12
25
  ### Changed
@@ -37,7 +50,10 @@ and this project adheres to [Semantic Versioning].
37
50
 
38
51
  [@skryukov]: https://github.com/skryukov
39
52
 
40
- [Unreleased]: https://github.com/skryukov/uri-idna/compare/v0.2.0...HEAD
53
+ [Unreleased]: https://github.com/skryukov/uri-idna/compare/v0.3.0...HEAD
54
+ [0.3.0]: https://github.com/skryukov/uri-idna/compare/v0.2.2...v0.3.0
55
+ [0.2.2]: https://github.com/skryukov/uri-idna/compare/v0.2.1...v0.2.2
56
+ [0.2.1]: https://github.com/skryukov/uri-idna/compare/v0.2.0...v0.2.1
41
57
  [0.2.0]: https://github.com/skryukov/uri-idna/compare/v0.1.0...v0.2.0
42
58
  [0.1.0]: https://github.com/skryukov/uri-idna/commits/v0.1.0
43
59
 
data/README.md CHANGED
@@ -155,7 +155,7 @@ char.downcase.ord
155
155
  #=> 12068
156
156
 
157
157
  # but UTS46 mapping does it's thing:
158
- URI::IDNA::UTS46::Mapping.call(char).ord
158
+ URI::IDNA::UTS46::Mapping.call(char).ord
159
159
  #=> 22823
160
160
 
161
161
  # so here is a full example:
@@ -203,7 +203,7 @@ URI::IDNA.whatwg_to_ascii("2003_rules.com")
203
203
 
204
204
  ##### Options
205
205
 
206
- - `be_strict`: `true` - `be_strict`: `true` – defines value of `use_std3_ascii_rules` UTS46 option.
206
+ - `be_strict`: `true` - defines value of `use_std3_ascii_rules` UTS46 option.
207
207
 
208
208
  ```ruby
209
209
  require "uri/idna"
@@ -260,6 +260,8 @@ To set directory for generated files, use `DEST_DIR` environment variable, e.g.
260
260
 
261
261
  Unicode data cached in the `tmp` directory by default, to change it, use `CACHE_DIR` environment variable, e.g. `CACHE_DIR=~/.cache/unicode_data bundle exec rake idna:generate`.
262
262
 
263
+ _Note: `rake idna:generate` might generate different results on different versions of Ruby due to usage of built-in Unicode normalization methods._
264
+
263
265
  ### Inspect Unicode data
264
266
 
265
267
  To inspect Unicode data, run `bundle exec rake 'idna:inspect[<HEX_CODE>]'`.
@@ -1,27 +1,33 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require_relative "validation/label"
4
- require_relative "validation/codepoint"
5
4
  require_relative "validation/bidi"
6
5
 
7
6
  module URI
8
7
  module IDNA
9
8
  class BaseProcessing
9
+ class << self
10
+ def default_options
11
+ @default_options ||= options_class.new
12
+ end
13
+
14
+ def options_class
15
+ raise NotImplementedError, "Implement #options_class method"
16
+ end
17
+ end
18
+
10
19
  def initialize(domain_name, **options)
11
20
  @domain_name = domain_name
12
- @options = options_class.new(**options)
21
+ @options = options.any? ? self.class.options_class.new(**options) : self.class.default_options
13
22
  end
14
23
 
15
24
  private
16
25
 
17
26
  attr_reader :domain_name, :options
18
27
 
19
- def options_class
20
- raise NotImplementedError, "Implement #options_class method"
21
- end
22
-
23
28
  def punycode_decode(label)
24
29
  raise Error, "Label contains non-ASCII code point" unless label.ascii_only?
30
+ raise Error, "A-label must not end with a hyphen" if label[-1] == "-"
25
31
 
26
32
  code = label[ACE_PREFIX.length..]
27
33
  raise Error, "Malformed A-label, no Punycode eligible content found" if code.empty?
@@ -39,7 +45,7 @@ module URI
39
45
  labels, trailing_dot = split_domain(domain)
40
46
 
41
47
  labels.map! do |label|
42
- raise Error, "Empty label" if label.empty?
48
+ raise Error, "Empty label" if label.empty? && options.verify_dns_length?
43
49
 
44
50
  yield label
45
51
  end
@@ -56,7 +62,7 @@ module URI
56
62
  labels = domain.split(".", -1)
57
63
  trailing_dot = labels[-1] && labels[-1].empty? ? labels.pop : false
58
64
 
59
- raise Error, "Empty domain" if labels.empty? || labels == [""]
65
+ raise Error, "Empty domain" if (labels.empty? || labels == [""]) && options.verify_dns_length?
60
66
 
61
67
  [labels, trailing_dot]
62
68
  end