spinel_kit 0.3.0 → 0.3.1

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: fca4df06c4d57130a5053954a6429beac7d6ce0d6f6d1ee26194753aea11732c
4
- data.tar.gz: 496c1116e14068768cb482723d1be6c6daebfc26f45d9972da3ab36d572eae69
3
+ metadata.gz: 84664f6fb19c07c1e9d4db180b7f9eb34a0499e6210de5acc764708b923aed72
4
+ data.tar.gz: 4a7894dca8991b6daf713423d04b33e35ef48678de58ea53112267a9cd7d679a
5
5
  SHA512:
6
- metadata.gz: 1d15a4186fd29c584767e64c7f015b6424ce72bae04d39b283529f48478923075662bc2ecdc5e0ac03a73c51bcc344a9140cc775123a33c02e2dc76f9860cf73
7
- data.tar.gz: 4d0ee98f92b44fa1e1345efdac6378626c31ba11c42cf0a6be12ab065f9e9854799eec16edb363da670b01eacd8421623631d2259c296f66f8b9892cd6f2eaa5
6
+ metadata.gz: e0599c94cabe3f168c4b1262e70dc66ef71eb2b9fc4a986e258a0040f1951c1e0ce59441f5d9eb881d251e16de7774ef0eb6a5f9b4b50c05969ccce9c2b6ebb9
7
+ data.tar.gz: 66a6080818ef6dd1d0ed4e9f19567ba903c4109cec84427971d7264cb3d316953db200c1fba64bab840f366a369f53b4bed789b253a43f788c2383092d6bce9d
data/CHANGELOG.md CHANGED
@@ -2,6 +2,18 @@
2
2
 
3
3
  All notable changes to SpinelKit are documented here.
4
4
 
5
+ ## [0.3.1] - 2026-11-12
6
+
7
+ ### Fixed
8
+ - **`SpinelKit::Url.escape` dropped all but the first byte of a multi-byte
9
+ character.** It indexed with `String#[]` and encoded `c.getbyte(0)`, on the
10
+ documented premise that `[]` indexes bytes under Spinel. It does not —
11
+ `"café".length` is 4 there and `[3]` is a two-byte `"é"` — so `"café"`
12
+ escaped to `"caf%C3"` on both runtimes, and that does not unescape back.
13
+ It now walks `bytesize`/`getbyte`. ASCII input and the `.b` form that the
14
+ parity test used are unchanged; what changes is that a plain UTF-8 string
15
+ now answers the same as its binary form.
16
+
5
17
  ## [0.3.0] - 2026-07-09
6
18
 
7
19
  ### Changed
data/spin.toml CHANGED
@@ -3,4 +3,4 @@
3
3
  # the repo keeps its historical name. See issue #3 for the repositioning.
4
4
  [package]
5
5
  name = "spinel_kit"
6
- version = "0.3.0"
6
+ version = "0.3.1"
data/spinel_kit/url.rb CHANGED
@@ -42,20 +42,26 @@ module SpinelKit
42
42
  # (ALPHA / DIGIT / `-._~`); the rest becomes `%XX` with UPPERCASE hex.
43
43
  # (Space -> `%20`, not `+` -- this is the URI-component, not form, encoder.)
44
44
  #
45
- # Byte-oriented: under Spinel `String#[]` indexes BYTES, so a multi-byte
46
- # UTF-8 char is encoded byte-by-byte (correct %XX of each byte). Under CRuby,
47
- # pass a binary string for the same behaviour (else `[]` splits on chars).
45
+ # Byte-oriented, and it walks BYTES to be so: `bytesize`/`getbyte` mean
46
+ # a multi-byte UTF-8 character becomes the %XX of each of its bytes on
47
+ # both runtimes, with no binary-string dance at the call site.
48
+ #
49
+ # It used to index with `String#[]` and encode `c.getbyte(0)` -- the
50
+ # FIRST byte of the character -- on the premise that `[]` indexes bytes
51
+ # under Spinel. It does not: `"caf\u00e9".length` is 4 there and `[3]`
52
+ # is a two-byte "\u00e9", so every byte but the first was DROPPED and
53
+ # "caf\u00e9" escaped to "caf%C3", which does not unescape back.
48
54
  def self.escape(s)
49
55
  out = ""
50
56
  i = 0
51
- while i < s.length
52
- c = s[i]
53
- if (c >= "a" && c <= "z") || (c >= "A" && c <= "Z") ||
54
- (c >= "0" && c <= "9") || c == "-" || c == "." ||
55
- c == "_" || c == "~"
56
- out = out + c
57
+ n = s.bytesize
58
+ while i < n
59
+ b = s.getbyte(i)
60
+ if (b >= 0x61 && b <= 0x7A) || (b >= 0x41 && b <= 0x5A) ||
61
+ (b >= 0x30 && b <= 0x39) || b == 0x2D || b == 0x2E ||
62
+ b == 0x5F || b == 0x7E
63
+ out = out + b.chr
57
64
  else
58
- b = c.getbyte(0)
59
65
  out = out + "%" + Hex.nibble_char(b / 16) + Hex.nibble_char(b % 16)
60
66
  end
61
67
  i += 1
@@ -2,5 +2,5 @@
2
2
  # without loading the rest of the library (the modules pull in no deps,
3
3
  # but this matches the toy/tep convention exactly).
4
4
  module SpinelKit
5
- VERSION = "0.3.0"
5
+ VERSION = "0.3.1"
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spinel_kit
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ori Pekelman