fix(client): parse a port-less bracketed IPv6 host in parseJoinCode#5178
Open
jeffrey701 wants to merge 1 commit into
Open
fix(client): parse a port-less bracketed IPv6 host in parseJoinCode#5178jeffrey701 wants to merge 1 commit into
jeffrey701 wants to merge 1 commit into
Conversation
Contributor
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
parseJoinCode splits host:port on the LAST colon. For a bracketed IPv6 literal with no port (e.g. `[::1]`), that colon is inside the address, so the host became `[:` and the join code resolved to a malformed `wss://[::1/ws`. Treat a host ending in `]` as bracketed-with-no-port and skip the split; a bracketed host that does carry a port (`[::1]:9000`) still splits correctly.
9c7738d to
bfc031a
Compare
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.
Problem
parseJoinCode(client/src/services/serverDetection.ts) splitshost:porton the last colon:For a bracketed IPv6 literal with no port (
[::1]), that last colon is inside the address, sohostbecomes"[:"and the join codeABC123@[::1]resolves to a malformed, unconnectablewss://[::1/ws.Fix
A bracketed host with no port ends in
], so add!hostPort.endsWith("]")to thehasPortcheck. A bracketed host that does carry a port ([::1]:9000) does not end in], so it still splits correctly.Test
client/src/services/__tests__/serverDetection.test.ts—[::1]resolves towss://[::1]/ws, and[::1]:9000still splits towss://[::1]:9000/ws.