ultimate_json_rpc 2.0.0 → 2.0.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: f45af26595bc5213dcf9c08cad72d1cc59f9bfc271ab41738c5b85b53cca4700
4
- data.tar.gz: 5103120fc4d68e4dbb5d2128ae557be55a46d2b018c89fcfd699cf9dd2815772
3
+ metadata.gz: 4f11babdb67d96cc22a45818500e53c13457f5a05e64ef821fd456fa7538b1c7
4
+ data.tar.gz: ab75d1e05982c873883b30e7dc8809d6da08a358dd934a5990b15017c01d92e0
5
5
  SHA512:
6
- metadata.gz: 01576525f8649d759117e23335c67c81491aae9b9514b6d29d02e99d8bb13756bb97387a2707954169fe2eb44ca0f52757851c8cf0f3ca8270618811ccb266a4
7
- data.tar.gz: 11b1f04708ec18d8acd99da8ab1c13cf79e00f7fdc86b9ba1b381870134af335df4d1c6dd8fe1aabce816efa1b72d5e68db7e305fc3cd298564c842136898320
6
+ metadata.gz: a2dcbffa2eb7ef3cc146e1183cc2098166e0631edffaf6311790baee8a6123de7c172b6b19dec7fa0cbcb31fb4e4ecf3f1e1c9c3b762db33d9ff350e93e31cf2
7
+ data.tar.gz: 3962bb3372d91f1ceea712bd42921db5ff66d45ce686ad871dedea2c865ce75391928c1db40d2dcb9298599eb9ffe9871e1e22aae1d56bf35bbf14a276371f5b
data/CHANGELOG.md CHANGED
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [2.0.1] - 2026-11-30
11
+
12
+ ### Fixed
13
+ - A request containing bytes that are not valid UTF-8 now gets `-32700 Parse error`. It used to be parsed anyway and then answered with `-32603 Internal error`, because the response could not be generated.
14
+
10
15
  ## [2.0.0] - 2026-11-30
11
16
 
12
17
  **2.0 removes everything the gem used to decide on your behalf.** It registers exactly the methods you tell it to: no name is refused, no name is skipped, nothing is put into the request context unless you put it there, and `rpc.discover` is not answered unless you register it. Every registered method is callable by anyone who can reach the server. Compare `server.methods_list` before and after upgrading; the README has an upgrade table.
@@ -218,7 +218,7 @@ module UltimateJsonRpc
218
218
  # env, authenticated user, ...). Each request starts with a copy of it as
219
219
  # its +request.context+.
220
220
  def handle(json_string, context: nil)
221
- data = @json.parse(json_string)
221
+ data = @json.parse(utf8(json_string))
222
222
  rescue StandardError
223
223
  @json.generate(Core::Response.error(Core::PARSE_ERROR, nil))
224
224
  else
@@ -261,6 +261,19 @@ module UltimateJsonRpc
261
261
 
262
262
  private
263
263
 
264
+ # JSON text is UTF-8 (RFC 8259), but the json gem does not check the bytes
265
+ # inside strings. Unchecked, an invalid byte travels into a method name or
266
+ # a param and surfaces later as an Internal error when the response cannot
267
+ # be generated. Bytes tagged as binary (a Rack body) are read as UTF-8.
268
+ def utf8(text)
269
+ return text unless text.is_a?(String)
270
+
271
+ text = text.dup.force_encoding(Encoding::UTF_8) if text.encoding == Encoding::BINARY
272
+ raise EncodingError, "request is not valid UTF-8" unless text.valid_encoding?
273
+
274
+ text
275
+ end
276
+
264
277
  def serialize_single(data, context = nil)
265
278
  request = parse_request(data, context)
266
279
  return request unless request.is_a?(Core::Request)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module UltimateJsonRpc
4
- VERSION = "2.0.0"
4
+ VERSION = "2.0.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ultimate_json_rpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.0.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andriy Tyurnikov