Rework host/hostname/authority implementation. #1561
This file contains 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
…ame`. u = URI("http://[::1]/bar") p u.hostname #=> "::1" p u.host #=> "[::1]"
With IPv6, any time we have a string which represents an authority, as defined by RFC7540, the address must be contained within square brackets, e.g.: "[2020::1985]:443". Representations from the `host` header and `authority` pseudo-header must conform to this format. Some headers, notably `x-forwarded-for` and `x-forwarded-host` do not format the authority correctly. So we introduce a private method `wrap_ipv6` which uses a heuristic to detect these situations and fix the formatting. Additionally, we introduce some new assertions in `Rack::Lint` to ensure SREVER_NAME and HTTP_HOST match the formatting requirements.
This was referenced
Mar 15, 2021
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.