Repository navigation
Reject a client id that isn't UTF-8 - #27
Merged
Merged
Conversation
PHP url-decodes cookie values, so a cookie holding %FF gives a client id with a byte that isn't UTF-8, which the database rejects like a client id over 255 bytes. ClientCookieJar now treats such a client id as invalid: read() ignores the cookie, so the visitor gets a new client id, and write() refuses to store one that a decorated client context returns.
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.
Summary
The 2.x counterpart of #26. PHP url-decodes cookie values, so a client cookie holding
%FFgives a client id with a byte that isn't UTF-8. That breaks the bundle's metadata column, and any application table that stores the client id.ClientCookieJar::isValid()now requires UTF-8 next to the existing rules, so the rule applies on both sides:ClientCookieJar::isValid(clientId) not empty at most 255 bytes + valid UTF-8 // preg_match('//u'), no ext-mbstring needed read() invalid → no cookie → the visitor gets a new client id write() invalid → LogicException ("must be a non-empty UTF-8 string of at most 255 bytes")README, UPGRADE-2.0.md and CLAUDE.md state the rule with UTF-8.
Evidence
src/change stashed, these fail:client-id-øis still read.Merge Danger
Door: two-way
Blast Radius: small
A visitor with such a cookie gets a new client id. An application whose client context decorator returns an id that isn't UTF-8 now gets a
LogicExceptionwhen the cookie is stored, like an empty id or one over 255 bytes already does on 2.x.