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

Fixes #5079 - :authority header for IPv6 address not having square br… #5128

Merged
merged 5 commits into from Aug 11, 2020

Conversation

sbordet
Copy link
Contributor

@sbordet sbordet commented Aug 7, 2020

…ackets.

On the client:

  • Origin.Address.host is passed through HostPort.normalizeHost(),
    so that if it is IPv6 is bracketed.
    Now the ipv6 address passed to an HttClient request is bracketed.
  • HttpRequest was de-bracketing the host, but now it does not anymore.

On the server:

  • Request.getLocalAddr(), getLocalName(), getRemoteAddr(),
    getRemoteHost(), getServerName(), when dealing with an IPv6 address,
    return it bracketed.
    The reason to return bracketed IPv6 also from *Addr() methods is that
    if it is used with InetAddress/InetSocketAddress it still works, but
    often it is interpreted as a URI host so brackets are necessary.
  • DoSFilter was blindly bracketing - now it does not.

Added a number of test cases, and fixed those that expected
non-bracketed IPv6.

Signed-off-by: Simone Bordet simone.bordet@gmail.com

…ackets.

On the client:
* Origin.Address.host is passed through HostPort.normalizeHost(),
so that if it is IPv6 is bracketed.
Now the ipv6 address passed to an `HttClient` request is bracketed.
* HttpRequest was de-bracketing the host, but now it does not anymore.

On the server:
* Request.getLocalAddr(), getLocalName(), getRemoteAddr(),
getRemoteHost(), getServerName(), when dealing with an IPv6 address,
return it bracketed.
The reason to return bracketed IPv6 also from *Addr() methods is that
if it is used with InetAddress/InetSocketAddress it still works, but
often it is interpreted as a URI host so brackets are necessary.
* DoSFilter was blindly bracketing - now it does not.

Added a number of test cases, and fixed those that expected
non-bracketed IPv6.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet requested review from gregw and joakime August 7, 2020 13:54
@joakime
Copy link
Contributor

joakime commented Aug 7, 2020

Some test failures in ...

  • org.eclipse.jetty.proxy.ForwardProxyServerTest
  • org.eclipse.jetty.proxy.ForwardProxyTLSServerTest

…ackets.

Fixed Jenkins failures by disabling tests that require IPv6 if it is not available.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
Copy link
Contributor

@gregw gregw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other than a niggle LGTM

* @return the host itself
* @deprecated no replacement, do not use it
*/
@Deprecated
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should the impl at least call HostPort.normalize so that it works if somebody does call it?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, perhaps add some apidoc text telling developers what the options are now that it's deprecated ...

/**
 * @deprecated use {@link HostPort#normalize(String)} instead.
 */
@Deprecated

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope, the method should not be used. It's protected so only subclasses could use it, but they should not - there is no need to normalize the host anymore.

I initially followed @gregw suggestion to call HostPort.normalizeHost(), but actually this method was doing exactly the opposite. So either restore the old behavior, or keep this new one that does nothing.

…ackets.

Updates after review.

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
…ackets.

Reverted code changes to HttpClient.normalizeHost().

Signed-off-by: Simone Bordet <simone.bordet@gmail.com>
@sbordet sbordet merged commit f73b282 into jetty-9.4.x Aug 11, 2020
@sbordet sbordet deleted the jetty-9.4.x-5079-ipv6_brackets branch August 11, 2020 18:04
@joakime joakime linked an issue Aug 11, 2020 that may be closed by this pull request
@joakime joakime added this to In progress in Jetty 9.4.32 via automation Aug 11, 2020
@joakime joakime moved this from In progress to Done in Jetty 9.4.32 Aug 11, 2020
@gregw gregw mentioned this pull request Sep 17, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
No open projects
Jetty 9.4.32
  
Done
Development

Successfully merging this pull request may close these issues.

:authority header for IPv6 address not having square brackets
3 participants