fix(auth): keep the session id when the continue URL already has a query - #2497
Open
demolaf wants to merge 4 commits into
Open
fix(auth): keep the session id when the continue URL already has a query#2497demolaf wants to merge 4 commits into
demolaf wants to merge 4 commits into
Conversation
Contributor
There was a problem hiding this comment.
Code Review
This pull request refactors ContinueUrlBuilder to correctly handle incoming URLs that already contain query parameters or fragments, ensuring appended parameters are correctly placed before the fragment. It also adds comprehensive unit tests for ContinueUrlBuilder and EmailLinkParser. The feedback recommends URL-encoding the parameter values appended to the continue URL to prevent breaking the URL structure with special characters, and adding a corresponding unit test to verify this behavior.
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.
ContinueUrlBuilderappended?unconditionally and then picked each parameter's separator by checking whether the last character was?. When a consumer's continue URL already had a query string the result carried two?and the first appended parameter was glued onto the consumer's last value — alwaysui_sid, the same-device session identifier, soisDifferentDeviceread the same device as a different one and email-link sign-in showed a spurious cross-device prompt. Parameters were also appended after a#fragment, where they aren't query parameters at all, and values were interpolated raw.The builder no longer does string surgery: it parses the URL once with
Uriand appends throughbuildUpon().appendQueryParameter(...), the same parserEmailLinkParserreads the parameters back with. Separator choice, fragment placement and percent-encoding all become the platform's job instead of something this class infers. A URL with nothing appended comes back unchanged.Added
ContinueUrlBuilderTestandEmailLinkParserTest— 27 tests, Robolectric so the URLs are read back through the realandroid.net.Uri. Neither class had any tests before; verified they fail on the old code and pass with the fix.Maintainer note: Fixes internal CPRN-434