simpleidn 0.2.2 → 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: 4bf696425445322cdf00f1c5937fb8ccc459e0a454d89c214f931a301150a31b
4
- data.tar.gz: 198f47ec8873752eca124b2d85d52288fecbf836a29fcfa0ceae28d669e4a691
3
+ metadata.gz: 8da67fb828aa058412a4960c2597150bc1b0398f09105233503f365180ed2943
4
+ data.tar.gz: dd94de768681589e3ab0f60dccbb0666c4a1668e9ebdd334e25c1cfc24c5f9ff
5
5
  SHA512:
6
- metadata.gz: 7edf0e005d6eba976d055262023ecb247f7fb8f3ae009269564511a5c41e0e01f62df7cf24a90be78d762c41c5558a5a7d25850a2da2e48c0680b1b22376abfd
7
- data.tar.gz: d95b222aa203f31bebac4af8c78b66938d76a6ebc09a747ee25a6fc3d148b5f6c293ed365a93a87666ea8df694e5302c94ca48cc8e283597a8cc63c8f7e34808
6
+ metadata.gz: cb81fc35814b5d7f0f273736ab9e849e45799ed04917d6629d794f2c35af41fd8a30066c0d709dea47e6f8849b657f45b0f77b8d0a830251e5d5f84a94eda324
7
+ data.tar.gz: fff721ec7eaa0831a8852525bd5ab292f8caacef97b58e737cf874b5755902c88b2b76f542909ef19128ef4d593ed70611548db14d61fa09cb0273fe52978cc4
data/CHANGELOG.md ADDED
@@ -0,0 +1,26 @@
1
+ # Changelog
2
+
3
+ ## 0.3.0 (2026-09-01)
4
+
5
+ - Update the UTS #46 / IDNA mapping table to Unicode 17.0.0 (was 15.1.0).
6
+ - `to_unicode` now raises `SimpleIDN::ConversionError` when an `xn--` label decodes to an empty or all-ASCII string. UTS #46 (Processing step 4.2) requires this, and it closes a spoofing loophole.
7
+ - Move CI from Travis to GitHub Actions. Test on Ruby 2.7–3.5, JRuby, and TruffleRuby, plus Windows and macOS.
8
+ - Reduce the packaged gem size. The gem no longer ships the raw `IdnaMappingTable.txt` source data.
9
+ - Add gemspec metadata (source code, changelog, bug tracker URIs) and require MFA for gem pushes.
10
+ - Convert the README to Markdown and expand the documentation.
11
+ - Add edge-case specs: encodings, frozen strings, emoji, transitional mode, alternative label separators, and the new error cases.
12
+
13
+ ## 0.2.3 (2024-05-22)
14
+
15
+ - Update the UTS #46 / IDNA mapping table to Unicode 15.1.
16
+ - Drop the `unf` runtime dependency. The gem now has no runtime dependencies.
17
+
18
+ ## 0.2.2 (2024-04-26)
19
+
20
+ - Fix file permissions in the packaged gem.
21
+
22
+ ## 0.2.1 (2021-01-14)
23
+
24
+ - Punycode and UTS #46 mapping fixes.
25
+
26
+ Earlier releases are not documented here. See the git history.
data/LICENCE CHANGED
@@ -1,21 +1,21 @@
1
- The MIT License
2
-
3
- Copyright (c) 2011-2017 Morten Møller Riis
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy
6
- of this software and associated documentation files (the "Software"), to deal
7
- in the Software without restriction, including without limitation the rights
8
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
- copies of the Software, and to permit persons to whom the Software is
10
- furnished to do so, subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in
13
- all copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
- THE SOFTWARE.
1
+ The MIT License
2
+
3
+ Copyright (c) 2011-2024 Morten Møller Riis
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,82 @@
1
+ # SimpleIDN
2
+
3
+ [![CI](https://github.com/mmriis/simpleidn/actions/workflows/ci.yml/badge.svg)](https://github.com/mmriis/simpleidn/actions/workflows/ci.yml)
4
+ [![Gem Version](https://badge.fury.io/rb/simpleidn.svg)](https://rubygems.org/gems/simpleidn)
5
+
6
+ This gem converts punycode ACE strings to unicode UTF-8 strings and vice versa. It is pure Ruby and has no runtime dependencies.
7
+
8
+ The punycode conversion is based on the RFC 3492 C example implementation. It is simplified and does not preserve case. Input is first mapped with the UTS #46 (IDNA Compatible Preprocessing) mapping table. The bundled mapping table is generated from **Unicode 17.0.0**.
9
+
10
+ The gem works with Ruby 2.2 and later, JRuby, and TruffleRuby.
11
+
12
+ ## Installation
13
+
14
+ ```
15
+ gem install simpleidn
16
+ ```
17
+
18
+ ## Usage
19
+
20
+ ```ruby
21
+ require 'simpleidn'
22
+
23
+ SimpleIDN.to_unicode("xn--mllerriis-l8a.com")
24
+ # => "møllerriis.com"
25
+
26
+ SimpleIDN.to_ascii("møllerriis.com")
27
+ # => "xn--mllerriis-l8a.com"
28
+ ```
29
+
30
+ ### Transitional processing
31
+
32
+ `to_ascii` and `to_unicode` accept an optional second argument, `transitional` (default `false`).
33
+ When `true`, the deviation characters `ß`, `ς`, ZWJ, and ZWNJ are mapped as in IDNA2003:
34
+
35
+ ```ruby
36
+ SimpleIDN.to_ascii("faß.de")
37
+ # => "xn--fa-hia.de"
38
+
39
+ SimpleIDN.to_ascii("faß.de", true)
40
+ # => "fass.de"
41
+ ```
42
+
43
+ Unicode removed transitional processing from UTS #46 in Unicode 16.0. The argument stays for backward compatibility. Use the default (`false`) unless you must match legacy IDNA2003 behavior.
44
+
45
+ ### Errors
46
+
47
+ Invalid input raises `SimpleIDN::ConversionError`, a subclass of `RangeError`:
48
+
49
+ ```ruby
50
+ SimpleIDN.to_unicode("xn---")
51
+ # => SimpleIDN::ConversionError
52
+ ```
53
+
54
+ This includes `xn--` labels that decode to an empty or all-ASCII string, as required by UTS #46.
55
+
56
+ ## Scope and known issues
57
+
58
+ - Case is not preserved.
59
+ - This is not a full UTS #46 / IDNA2008 implementation. The gem maps and converts labels. It does not enforce validity rules such as bidi rules, joiner context rules, or label length limits.
60
+
61
+ Please report any issues!
62
+
63
+ ## Development
64
+
65
+ Run the tests:
66
+
67
+ ```
68
+ bundle install
69
+ bundle exec rspec
70
+ ```
71
+
72
+ The test suite includes the official Unicode `IdnaTestV2.txt` conformance vectors and the JOSEFSSON test vectors.
73
+
74
+ To update the UTS #46 mapping table, download the new `IdnaMappingTable.txt` and `IdnaTestV2.txt` from [unicode.org](https://www.unicode.org/Public/idna/latest/) into `tables/` and `spec/`, then regenerate:
75
+
76
+ ```
77
+ ruby tables/generate_mapping_table.rb tables/IdnaMappingTable.txt > lib/simpleidn/uts46mapping.rb
78
+ ```
79
+
80
+ ## License
81
+
82
+ MIT. See [LICENCE](LICENCE).