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 +4 -4
- data/CHANGELOG.md +5 -0
- data/lib/ultimate_json_rpc/server.rb +14 -1
- data/lib/ultimate_json_rpc/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 4f11babdb67d96cc22a45818500e53c13457f5a05e64ef821fd456fa7538b1c7
|
|
4
|
+
data.tar.gz: ab75d1e05982c873883b30e7dc8809d6da08a358dd934a5990b15017c01d92e0
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
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)
|