Captive portal: fix bracketed IPv6 literal in redirurl regex#9981
Merged
swhite2 merged 1 commit intoopnsense:masterfrom Mar 17, 2026
Merged
Conversation
The host-match regex ([^:/]+) in the IPv6 lighttpd socket blocks truncates bracketed IPv6 literals at the first colon, producing a broken redirurl (e.g. [2601/ instead of [2606:4700:4700::1111]/). Change the capture group to (\[[^\]]+\]|[^:/]+) so a full bracketed literal is matched first, falling back to the original pattern for IPv4 addresses and hostnames. Missed in: 369630d (Captive portal: IPv6 support, opnsense#9745) See also: opnsense#9973
Contributor
Author
|
I found this was missed in the previous captive portal changes, @AdSchellevis @swhite2 do you mind taking a look? |
swhite2
approved these changes
Mar 17, 2026
Member
|
Merged, thanks :) |
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
Follow-up to #9745 (Captive portal: IPv6 support). The host-match regex fix from #9973 was not included when #9745 merged.
When a client reaches the captive portal via a raw IPv6 address, the
Hostheader contains a bracketed literal (e.g.[2606:4700:4700::1111]). The regex([^:/]+)stops at the first colon, so the redirect URL becomes[2601/instead of[2606:4700:4700::1111]/.This PR updates the regex to
(\[[^\]]+\]|[^:/]+)so full bracketed IPv6 literals are matched first, with the original pattern still used for IPv4 and hostnames.Testing
Lab overview
3d06:bad:b01:200::11/128LAN:
3d06:bad:b01:210::1/643d06:bad:b01:210::902/64redirurlredirurl=[2606/redirurl=[2606:4700:4700::1111]/Missed in: 369630d (Captive portal: IPv6 support, #9745)
See also: #9973