simpleidn 0.2.3 → 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: bc28e3f1151e0c2355f2e74c9d86c2a4d3df9a3154ceec4b6e5d40c59e47f9a3
4
- data.tar.gz: 294aeff28e2d897eb97e311d5758449ea474ad82d08ef421ddd5276464379e51
3
+ metadata.gz: 8da67fb828aa058412a4960c2597150bc1b0398f09105233503f365180ed2943
4
+ data.tar.gz: dd94de768681589e3ab0f60dccbb0666c4a1668e9ebdd334e25c1cfc24c5f9ff
5
5
  SHA512:
6
- metadata.gz: 688866028bccaeb4a80d863a020f7c0604575a60532c8fd2dc99780e6a3b9e7a1213dad7f2cab2533e8c78a947ce6ae029570b9394fbe30d9a1970779b074f35
7
- data.tar.gz: a105c8a6ecd3f25fe3253c789896011c487567a9ed4fabf529f6080f7ef648343e0592fd4440d6edbe9423d0263ee30d0aa9a602d3618b83f1b67a3a1656fa66
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-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.
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).
@@ -1,13 +1,13 @@
1
1
  # encoding: UTF-8
2
2
 
3
3
  # IdnaMappingTable.txt
4
- # Date: 2023-08-10, 22:32:27 GMT
5
- # © 2023 Unicode®, Inc.
4
+ # Date: 2025-07-25, 18:08:44 GMT
5
+ # © 2025 Unicode®, Inc.
6
6
  # Unicode and the Unicode Logo are registered trademarks of Unicode, Inc. in the U.S. and other countries.
7
- # For terms of use, see https://www.unicode.org/terms_of_use.html
7
+ # For terms of use and license, see https://www.unicode.org/terms_of_use.html
8
8
  #
9
9
  # Unicode IDNA Compatible Preprocessing for UTS #46
10
- # Version: 15.1.0
10
+ # Version: 17.0.0
11
11
  #
12
12
  # For documentation and usage, see https://www.unicode.org/reports/tr46
13
13
  #
@@ -456,6 +456,7 @@ module SimpleIDN
456
456
  1210 => 1211,
457
457
  1212 => 1213,
458
458
  1214 => 1215,
459
+ 1216 => 1231,
459
460
  1217 => 1218,
460
461
  1219 => 1220,
461
462
  1221 => 1222,
@@ -597,18 +598,61 @@ module SimpleIDN
597
598
  4007 => [4006, 4023],
598
599
  4012 => [4011, 4023],
599
600
  4025 => [3984, 4021],
601
+ 4256 => 11520,
602
+ 4257 => 11521,
603
+ 4258 => 11522,
604
+ 4259 => 11523,
605
+ 4260 => 11524,
606
+ 4261 => 11525,
607
+ 4262 => 11526,
608
+ 4263 => 11527,
609
+ 4264 => 11528,
610
+ 4265 => 11529,
611
+ 4266 => 11530,
612
+ 4267 => 11531,
613
+ 4268 => 11532,
614
+ 4269 => 11533,
615
+ 4270 => 11534,
616
+ 4271 => 11535,
617
+ 4272 => 11536,
618
+ 4273 => 11537,
619
+ 4274 => 11538,
620
+ 4275 => 11539,
621
+ 4276 => 11540,
622
+ 4277 => 11541,
623
+ 4278 => 11542,
624
+ 4279 => 11543,
625
+ 4280 => 11544,
626
+ 4281 => 11545,
627
+ 4282 => 11546,
628
+ 4283 => 11547,
629
+ 4284 => 11548,
630
+ 4285 => 11549,
631
+ 4286 => 11550,
632
+ 4287 => 11551,
633
+ 4288 => 11552,
634
+ 4289 => 11553,
635
+ 4290 => 11554,
636
+ 4291 => 11555,
637
+ 4292 => 11556,
638
+ 4293 => 11557,
600
639
  4295 => 11559,
601
640
  4301 => 11565,
602
641
  4348 => 4316,
642
+ 4447 => [],
643
+ 4448 => [],
603
644
  5112 => 5104,
604
645
  5113 => 5105,
605
646
  5114 => 5106,
606
647
  5115 => 5107,
607
648
  5116 => 5108,
608
649
  5117 => 5109,
650
+ 6068 => [],
651
+ 6069 => [],
609
652
  6155 => [],
610
653
  6156 => [],
611
654
  6157 => [],
655
+ 6158 => [],
612
656
  6159 => [],
613
657
  7296 => 1074,
614
658
  7297 => 1076,
@@ -619,6 +663,7 @@ module SimpleIDN
619
663
  7302 => 1098,
620
664
  7303 => 1123,
621
665
  7304 => 42571,
666
+ 7305 => 7306,
622
667
  7312 => 4304,
623
668
  7313 => 4305,
624
669
  7314 => 4306,
@@ -1073,7 +1118,16 @@ module SimpleIDN
1073
1118
  8279 => [8242, 8242, 8242, 8242],
1074
1119
  8287 => 32,
1075
1120
  8288 => [],
1121
+ 8289 => [],
1122
+ 8290 => [],
1123
+ 8291 => [],
1076
1124
  8292 => [],
1125
+ 8298 => [],
1126
+ 8299 => [],
1127
+ 8300 => [],
1128
+ 8301 => [],
1129
+ 8302 => [],
1130
+ 8303 => [],
1077
1131
  8304 => 48,
1078
1132
  8305 => 105,
1079
1133
  8308 => 52,
@@ -1155,6 +1209,7 @@ module SimpleIDN
1155
1209
  8495 => 101,
1156
1210
  8496 => 101,
1157
1211
  8497 => 102,
1212
+ 8498 => 8526,
1158
1213
  8499 => 109,
1159
1214
  8500 => 111,
1160
1215
  8501 => 1488,
@@ -1221,6 +1276,7 @@ module SimpleIDN
1221
1276
  8573 => 99,
1222
1277
  8574 => 100,
1223
1278
  8575 => 109,
1279
+ 8579 => 8580,
1224
1280
  8585 => [48, 8260, 51],
1225
1281
  8748 => [8747, 8747],
1226
1282
  8749 => [8747, 8747, 8747],
@@ -1748,6 +1804,7 @@ module SimpleIDN
1748
1804
  12641 => 4467,
1749
1805
  12642 => 4468,
1750
1806
  12643 => 4469,
1807
+ 12644 => [],
1751
1808
  12645 => 4372,
1752
1809
  12646 => 4373,
1753
1810
  12647 => 4551,
@@ -2425,9 +2482,17 @@ module SimpleIDN
2425
2482
  42950 => 7566,
2426
2483
  42951 => 42952,
2427
2484
  42953 => 42954,
2485
+ 42955 => 612,
2486
+ 42956 => 42957,
2487
+ 42958 => 42959,
2428
2488
  42960 => 42961,
2489
+ 42962 => 42963,
2490
+ 42964 => 42965,
2429
2491
  42966 => 42967,
2430
2492
  42968 => 42969,
2493
+ 42970 => 42971,
2494
+ 42972 => 411,
2495
+ 42993 => 115,
2431
2496
  42994 => 99,
2432
2497
  42995 => 102,
2433
2498
  42996 => 113,
@@ -4005,6 +4070,7 @@ module SimpleIDN
4005
4070
  65437 => 12531,
4006
4071
  65438 => 12441,
4007
4072
  65439 => 12442,
4073
+ 65440 => [],
4008
4074
  65441 => 4352,
4009
4075
  65442 => 4353,
4010
4076
  65443 => 4522,
@@ -4288,6 +4354,28 @@ module SimpleIDN
4288
4354
  68784 => 68848,
4289
4355
  68785 => 68849,
4290
4356
  68786 => 68850,
4357
+ 68944 => 68976,
4358
+ 68945 => 68977,
4359
+ 68946 => 68978,
4360
+ 68947 => 68979,
4361
+ 68948 => 68980,
4362
+ 68949 => 68981,
4363
+ 68950 => 68982,
4364
+ 68951 => 68983,
4365
+ 68952 => 68984,
4366
+ 68953 => 68985,
4367
+ 68954 => 68986,
4368
+ 68955 => 68987,
4369
+ 68956 => 68988,
4370
+ 68957 => 68989,
4371
+ 68958 => 68990,
4372
+ 68959 => 68991,
4373
+ 68960 => 68992,
4374
+ 68961 => 68993,
4375
+ 68962 => 68994,
4376
+ 68963 => 68995,
4377
+ 68964 => 68996,
4378
+ 68965 => 68997,
4291
4379
  71840 => 71872,
4292
4380
  71841 => 71873,
4293
4381
  71842 => 71874,
@@ -4352,10 +4440,71 @@ module SimpleIDN
4352
4440
  93789 => 93821,
4353
4441
  93790 => 93822,
4354
4442
  93791 => 93823,
4443
+ 93856 => 93883,
4444
+ 93857 => 93884,
4445
+ 93858 => 93885,
4446
+ 93859 => 93886,
4447
+ 93860 => 93887,
4448
+ 93861 => 93888,
4449
+ 93862 => 93889,
4450
+ 93863 => 93890,
4451
+ 93864 => 93891,
4452
+ 93865 => 93892,
4453
+ 93866 => 93893,
4454
+ 93867 => 93894,
4455
+ 93868 => 93895,
4456
+ 93869 => 93896,
4457
+ 93870 => 93897,
4458
+ 93871 => 93898,
4459
+ 93872 => 93899,
4460
+ 93873 => 93900,
4461
+ 93874 => 93901,
4462
+ 93875 => 93902,
4463
+ 93876 => 93903,
4464
+ 93877 => 93904,
4465
+ 93878 => 93905,
4466
+ 93879 => 93906,
4467
+ 93880 => 93907,
4355
4468
  113824 => [],
4356
4469
  113825 => [],
4357
4470
  113826 => [],
4358
4471
  113827 => [],
4472
+ 117974 => 97,
4473
+ 117975 => 98,
4474
+ 117976 => 99,
4475
+ 117977 => 100,
4476
+ 117978 => 101,
4477
+ 117979 => 102,
4478
+ 117980 => 103,
4479
+ 117981 => 104,
4480
+ 117982 => 105,
4481
+ 117983 => 106,
4482
+ 117984 => 107,
4483
+ 117985 => 108,
4484
+ 117986 => 109,
4485
+ 117987 => 110,
4486
+ 117988 => 111,
4487
+ 117989 => 112,
4488
+ 117990 => 113,
4489
+ 117991 => 114,
4490
+ 117992 => 115,
4491
+ 117993 => 116,
4492
+ 117994 => 117,
4493
+ 117995 => 118,
4494
+ 117996 => 119,
4495
+ 117997 => 120,
4496
+ 117998 => 121,
4497
+ 117999 => 122,
4498
+ 118000 => 48,
4499
+ 118001 => 49,
4500
+ 118002 => 50,
4501
+ 118003 => 51,
4502
+ 118004 => 52,
4503
+ 118005 => 53,
4504
+ 118006 => 54,
4505
+ 118007 => 55,
4506
+ 118008 => 56,
4507
+ 118009 => 57,
4359
4508
  119134 => [119127, 119141],
4360
4509
  119135 => [119128, 119141],
4361
4510
  119136 => [119128, 119141, 119150],
@@ -4363,6 +4512,14 @@ module SimpleIDN
4363
4512
  119138 => [119128, 119141, 119152],
4364
4513
  119139 => [119128, 119141, 119153],
4365
4514
  119140 => [119128, 119141, 119154],
4515
+ 119155 => [],
4516
+ 119156 => [],
4517
+ 119157 => [],
4518
+ 119158 => [],
4519
+ 119159 => [],
4520
+ 119160 => [],
4521
+ 119161 => [],
4522
+ 119162 => [],
4366
4523
  119227 => [119225, 119141],
4367
4524
  119228 => [119226, 119141],
4368
4525
  119229 => [119225, 119141, 119150],
@@ -5851,6 +6008,7 @@ module SimpleIDN
5851
6008
  194661 => 23000,
5852
6009
  194662 => 23142,
5853
6010
  194663 => 14062,
6011
+ 194664 => 14076,
5854
6012
  194665 => 23304,
5855
6013
  194666 => 23358,
5856
6014
  194667 => 23358,
@@ -5862,6 +6020,7 @@ module SimpleIDN
5862
6020
  194673 => 138008,
5863
6021
  194674 => 23551,
5864
6022
  194675 => 23558,
6023
+ 194676 => 24403,
5865
6024
  194677 => 23586,
5866
6025
  194678 => 14209,
5867
6026
  194679 => 23648,
@@ -6032,6 +6191,7 @@ module SimpleIDN
6032
6191
  194844 => 28997,
6033
6192
  194845 => 148067,
6034
6193
  194846 => 29084,
6194
+ 194847 => 148395,
6035
6195
  194848 => 29224,
6036
6196
  194849 => 29237,
6037
6197
  194850 => 29264,
@@ -6095,6 +6255,7 @@ module SimpleIDN
6095
6255
  194908 => 153980,
6096
6256
  194909 => 154279,
6097
6257
  194910 => 154279,
6258
+ 194911 => 31470,
6098
6259
  194912 => 16898,
6099
6260
  194913 => 154539,
6100
6261
  194914 => 31686,
@@ -6190,6 +6351,7 @@ module SimpleIDN
6190
6351
  195004 => 34600,
6191
6352
  195005 => 34667,
6192
6353
  195006 => 34694,
6354
+ 195007 => 17879,
6193
6355
  195008 => 34785,
6194
6356
  195009 => 34817,
6195
6357
  195010 => 17913,
@@ -1,3 +1,3 @@
1
1
  module SimpleIDN
2
- VERSION = "0.2.3"
2
+ VERSION = "0.3.0"
3
3
  end