From 4f990cadea6ba673f2168705e18f20d39dad9781 Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Sat, 4 Jul 2026 14:47:33 +0100 Subject: [PATCH 1/3] remove dead code --- lib/http/2/connection.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/http/2/connection.rb b/lib/http/2/connection.rb index 45a597e..6e74bc9 100644 --- a/lib/http/2/connection.rb +++ b/lib/http/2/connection.rb @@ -399,7 +399,6 @@ def receive(data) unless @streams_recently_closed.key?(stream_id) connection_error(:protocol_error, msg: "sent window update on idle stream") end - stream = @streams_recently_closed[stream_id] process_window_update(frame: frame, encode: true) # Endpoints MUST ignore # WINDOW_UPDATE or RST_STREAM frames received in this state (closed), though From dc550fb86681123d1e0b0511930ed4dd027840a2 Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Sat, 4 Jul 2026 14:49:38 +0100 Subject: [PATCH 2/3] fix String#bytesplice usage, which in order to be able to cut UTF-8 characters, requires the string to be encoded as binary, otherwise it'll raise a range error most of the strings passed to #read_str come from downstream usage of itself, so there are more chances of reducing string creation by returning binary strings --- lib/http/2/extensions.rb | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/http/2/extensions.rb b/lib/http/2/extensions.rb index b0c4ed7..56f6acb 100644 --- a/lib/http/2/extensions.rb +++ b/lib/http/2/extensions.rb @@ -26,9 +26,16 @@ def append_str(str, data) def read_str(str, n) return "".b if n == 0 + enc = str.encoding + + if enc != Encoding::BINARY + str = str.dup if str.frozen? + str.force_encoding(Encoding::BINARY) + end + chunk = str.byteslice(0, n) str.bytesplice(0, chunk.length, "") - chunk + chunk.force_encoding(Encoding::BINARY) end else def read_str(str, n) @@ -37,7 +44,7 @@ def read_str(str, n) chunk = str.byteslice(0, n) remaining = str.byteslice(n, str.size - n) remaining ? str.replace(remaining) : str.clear - chunk + chunk.force_encoding(Encoding::BINARY) end end From bf3cdc01e890d2bc197c7144a042849138170d12 Mon Sep 17 00:00:00 2001 From: HoneyryderChuck Date: Mon, 6 Jul 2026 12:23:07 +0100 Subject: [PATCH 3/3] bump version to 1.2.1 --- CHANGELOG.md | 4 ++++ lib/http/2/version.rb | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7f2b348..6006603 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.2.1 + +* fix: encode the string to binary when using `String#bytesplice` (if the string is UTF-8 and the range would split multibyte characters, bytesplicing raises an error). + ## 1.2.0 ### Improvements diff --git a/lib/http/2/version.rb b/lib/http/2/version.rb index 41879aa..116280a 100644 --- a/lib/http/2/version.rb +++ b/lib/http/2/version.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true module HTTP2 - VERSION = "1.2.0" + VERSION = "1.2.1" end