You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Encode binary cache keys as ucs-2 strings (#71224)
Stacked on top of #71221
Originally I had intended for CacheHandlers to be able to pick their
ideal encoding for performance and size. When binary cache keys are
involved. However, we sometimes have to add our own caching on top of
the handler anyway.
Since there's no built-in binary hash map implementation in JS itself,
it's easier to use strings for this. It's also a simpler protocol if
it's always a string type.
It's possible to use UCS-2 encoding in JS which allows for arbitrary
bytes. So that's what I'm doing in this PR. In the common case, it just
looks the same as ~UTF-8~ ASCII strings so it's more compact than
Base64.
As long as this doesn't pass a UTF-8 encoded boundary which would then
error. That's easy to mess up because they often default to serializing
invalid characters with the same character - which would lead to
potential cache poisoning because different arguments would look the
same. However, it is possible to get UCS-2 sequences into JS in other
ways, so maybe this issue already exists anyway?
With this PR a CacheHandler just have to handle strings - it just have
to be aware that they might not be valid Unicode strings.
0 commit comments