Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Relax parsing restrictions around host and hostname #1606

Merged
merged 2 commits into from Feb 16, 2020

Commits on Feb 16, 2020

  1. Remove parsing restrictions around host and hostname

    This approach allows us to match and process any potential input and still meet the contractual requirements of `Request#split_authority` _without_ requiring the input to be well-formed or RFC-compliant.  In turn, this eliminates unexpected failures on invalid-but-functional inputs.
    
    If we deemed it necessary to do validation (particularly on IP addresses), the `AUTHORITY` regex still provides enough context on which validations should apply, though doing so would require some consideration on what should be returned upon validation failure.
    
    If validations can be ruled unnecessary – I suspect this should be the case – the implementation could be replaced by the semantically identical:
    
    ``` ruby
    def split_authority(authority)
      /\A(?<host>\[\g<addr>\]|(?<addr>.*?))(:(?<port>\d+))?\Z/ =~ authority
      return host, addr, port&.to_i
    end
    ```
    
    This gives up differentiation between IPv6, IPv4, and DNS addresses, but is arguably simpler.
    pvande committed Feb 16, 2020
    Copy the full SHA
    e842925 View commit details
    Browse the repository at this point in the history
  2. Add a CHANGELOG.md entry

    pvande committed Feb 16, 2020
    Copy the full SHA
    97efb68 View commit details
    Browse the repository at this point in the history