encoded_id 1.1.0 → 1.1.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: cc85ee43787e3ddbbdd901dccd4a092024e9a2738a8e3534a116b584936835af
4
- data.tar.gz: f5826733ed26045fc433a1380b914ec7d6fb8487e60d134887fc0fb2bfed823c
3
+ metadata.gz: dc2bbc18ff01120cbffad63845d87478ea6db88bc5496e852238300971264ee0
4
+ data.tar.gz: 63eba94f1326b52e3f905c8770e4773c763693187fd7772aac0749f53b8ac367
5
5
  SHA512:
6
- metadata.gz: c6d2a3bcd18dba39d2f2c203ed69aa995a595608719338668bb63ecc548a145f99292951b6e3941ab2009972e155320ebea2cbc301e740881cd205c1b51b1065
7
- data.tar.gz: f8c907d4757dd94a4b84789f10a2ab260d2e2da3607f13aaceeda3ee99c7a86252ebf0e7976dfbecebafc9998db901fff8543dacf4cb0ed9492ef912a2932fd3
6
+ metadata.gz: a114034b52cd2eb7ab5888ab86114c57b0ce7d7f18e82c7a4ed99640131185be4b6ed2dc8544b41f1e5da5372f6dda9fdc4c854852e07d9d8f531daf6bf3a219
7
+ data.tar.gz: 542bdeea7c933cc8fe67516cf4e02cdd84a1136ed224d687cf1f9d7f0fd9508205c348b01a0933e71fa1f24db53c87515cf70c742c8011553586839225b19b8b
data/CHANGELOG.md CHANGED
@@ -1,6 +1,19 @@
1
1
  ## [Unreleased]
2
2
 
3
- - nothing yet
3
+ ## [1.1.1] - 2026-10-07
4
+
5
+ ### Fixed
6
+
7
+ - The Sqids encoder now only decodes strings that are the canonical encoding of the decoded values, matching the Hashids encoder. Previously many strings that were never issued (e.g. `"42"`) decoded to an ID, which let arbitrary strings resolve to records via the Rails finders.
8
+
9
+ ### Upgrade notes
10
+
11
+ - **Sqids IDs must now match your current configuration exactly.** Previously Sqids accepted near-miss strings, which meant old IDs kept working after some config changes. They no longer do (Hashids has always behaved this way). Before upgrading, check whether you changed any of these after IDs were issued:
12
+ - `id_length`: all IDs issued under the old length stop resolving.
13
+ - the blocklist, `blocklist_mode` or `blocklist_max_length`: IDs that the new settings would issue differently (those containing a newly blocked word) stop resolving.
14
+ - `downcase_on_decode` with an alphabet containing uppercase letters: IDs containing those letters stop resolving.
15
+
16
+ Changing the separator, group size or character mappings is unaffected.
4
17
 
5
18
  ## [1.1.0] - 2026-01-23
6
19
 
@@ -47,7 +47,11 @@ module EncodedId
47
47
  def decode(hash)
48
48
  return [] if hash.nil? || hash.empty?
49
49
 
50
- @sqids.decode(hash)
50
+ decoded = @sqids.decode(hash)
51
+ return [] if decoded.empty? || decoded.any? { _1 > ::MySqids.max_value }
52
+ return [] if @sqids.encode(decoded) != hash
53
+
54
+ decoded
51
55
  rescue
52
56
  raise InvalidInputError, "unable to unhash"
53
57
  end
@@ -3,5 +3,5 @@
3
3
  # rbs_inline: enabled
4
4
 
5
5
  module EncodedId
6
- VERSION = "1.1.0"
6
+ VERSION = "1.1.1"
7
7
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: encoded_id
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stephen Ierodiaconou
@@ -75,7 +75,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  - !ruby/object:Gem::Version
76
76
  version: '0'
77
77
  requirements: []
78
- rubygems_version: 3.6.7
78
+ rubygems_version: 4.0.3
79
79
  specification_version: 4
80
80
  summary: EncodedId is a gem for creating reversible obfuscated IDs from numerical
81
81
  IDs. It uses Sqids by default.