Ascii85 2.0.2 → 3.0.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: 6866b24599936a3644853d934a6df51cd4c010e6ae2dd74bd1e0136b930a20bb
4
- data.tar.gz: d2a7ca24ff02f36e287b9171df96c4f0d31f2377b312185fe4ea637dcb23ea3c
3
+ metadata.gz: 7a0c833dddbc0ab5c562235851c6ddbb5a665513558e0e19edff7d3e48f37260
4
+ data.tar.gz: 9d665702782013875a0e2ea91140e46226ea5079af96a864cfbdedb6ff26d748
5
5
  SHA512:
6
- metadata.gz: 88c6434f72cd175bc15d258bcf21e863fc2fcfdc05cd5cecbffeb2d4a6265734be9e327bd0d64d1c3e4ce0a83fffab396df55c33f2f8f80e7ad9ba7c5301502c
7
- data.tar.gz: 7834017172e9aefc7ade9d9bcc4b3ba90cc4f4a2472a7cdeea31ce95ade21166adbb1e9e54c78e1bb587386404952c3c61118e0b35b9cd670fac612a72c472c5
6
+ metadata.gz: 5951d3f4d56808d2dcb85958e4aef1cc06d8078a9343fd93fff1379ccab5dfbe165bb951461702239bcf2a8b20456f9c2f69da2eea03ecfcc0e2fedefd69a787
7
+ data.tar.gz: aa1d7152dcd89bb29b22a6ab0caa0b3aaed8f1d7587b6a41e23b6ecea4a5b9683dc0d0987d56d438b4b52c83d675236e6c1fea7b59f84838e9f4993ad2eb59f7
data/CHANGELOG.md CHANGED
@@ -1,5 +1,24 @@
1
1
  # Ascii85 Changelog
2
2
 
3
+ ## [3.0.0] - 2026-11-29
4
+
5
+ This release does not affect normal use, but the changes are backwards-
6
+ incompatible when non-canonical input is provided.
7
+
8
+ ### BREAKING CHANGES
9
+
10
+ The decoder output changes for non-canonical input in the last tuple. Input
11
+ is non-canonical if the encoder does not produce it from the string the tuple
12
+ decodes to (it does not round-trip).
13
+
14
+ ### Fixed
15
+
16
+ - Fixed an off-by-one error in decoding trailing tuples (Issue #11).
17
+
18
+ The fix corrects the padding used for incomplete trailing tuples, resulting
19
+ in output that is sometimes different from version 2.0.2 for non-canonical
20
+ input. The previous output could be too large by `1`.
21
+
3
22
  ## [2.0.2] - 2026-11-21
4
23
 
5
24
  ### Fixed
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Ascii85
4
- VERSION = '2.0.2'
4
+ VERSION = '3.0.0'
5
5
  end
data/lib/ascii85.rb CHANGED
@@ -299,9 +299,10 @@ module Ascii85
299
299
 
300
300
  raise(Ascii85::DecodingError, 'Last 5-tuple consists of single character') if count == 1
301
301
 
302
- # Finish last, partially decoded 32-bit word
302
+ # Finish last, partially decoded 32-bit word by padding it with 'u'
303
+ # characters (84 each), which adds 85**(5 - count) - 1 to the word.
303
304
  count -= 1
304
- word += lut[count]
305
+ word += lut[count] - 1
305
306
 
306
307
  raise(Ascii85::DecodingError, "Invalid Ascii85 5-tuple (#{word} >= 2**32)") if word > 0xffffffff
307
308
 
@@ -206,6 +206,13 @@ describe Ascii85 do
206
206
  assert_equal 'Ruby', output.string
207
207
  end
208
208
 
209
+ it 'should pad the last, partial tuple with u characters' do
210
+ # Non-canonical tuples where padding with u (84) gives a different
211
+ # result than adding one more (85).
212
+ assert_equal "\x1C8".b, Ascii85.decode("<~*'!~>")
213
+ assert_equal "\xC7\x92\xF9".b, Ascii85.decode('<~a--8~>')
214
+ end
215
+
209
216
  describe 'Error conditions' do
210
217
  it 'should raise DecodingError if it encounters a word >= 2**32' do
211
218
  assert_raises(Ascii85::DecodingError) { Ascii85.decode('<~s8W-#~>') }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: Ascii85
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 3.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Johannes Holzfuß