Repository navigation
fix(client): replace lone UTF-16 surrogates instead of dropping the message - #648
Merged
Merged
Conversation
…essage Chrome sends binary request bodies, e.g. a Blob upload paused by blacklist=/whitelist=, and broken page text with lone surrogates that the json gem rejects. The fallback unescaped every \uXXXX, which broke messages with escaped control characters, so Fetch.requestPaused was dropped and the request hung. Only lone surrogates are replaced with U+FFFD now. Refs rubycdp/cuprite#308
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes rubycdp/cuprite#308.
With
blacklist=/whitelist=(Cuprite'surl_blacklist), every request is paused withFetch.requestPauseduntil Ferrum continues or aborts it. For an in-memoryBlobbody, Chrome includes the raw bytes aspostData, and some byte sequences come out as lone UTF-16 surrogates, e.g.ED BD B5→\udf75. Thejsongem rejects lone leading surrogates on every version and lone trailing ones since 3.x. The fallback from #452 unescaped every\uXXXX, which turned escaped control characters into raw ones and failed as well. So the message was dropped,Fetch.continueRequestwas never sent, and the upload hung. Rails 8's ActiveStorage direct upload sendsfile.slice(), aBlob, so it hit this after upgrading from 7.2.When the first parse fails, only lone surrogate escapes are replaced with
�. Escapes are matched left to right, so valid pairs,\",\\and control-character escapes stay as they are.Behavior change: broken text set from JS (#452's case) now reads as
�instead of???. The existing spec is updated.url_blacklistxhr.send(file)xhr.send(file.slice())fetchwithnew Blob([...])The new spec uploads a
Blobwith a lone leading surrogate, a quote, a backslash, NUL and a newline while a blacklist is set. Without the fix it raisesFerrum::TimeoutError. Ferrum's bundle hasjson2.18; I also checked that the real 300 KB message from the report parses withjson3.1.0.