Skip to content

Support multiple comma-separated values in X-Forwarded-Host header [SPR-11140] #15766

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

Closed
spring-projects-issues opened this issue Dec 2, 2013 · 2 comments
Assignees
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

spring-projects-issues commented Dec 2, 2013

Chris Pimlott opened SPR-11140 and commented

The support for the X-Forwarded-Host header added in #14743 does not account for having multiple comma-separated hosts in the header, e.g.:

X-Forwarded-Host: foo.com, bar.com, baz.com

Test case:

  @Test
  public void testMultiValuedXForwardedHostHeader() {
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.addHeader("X-Forwarded-Host", "a.example.org, b.example.org, c.example.org");

    assertEquals("a.example.org", ServletUriComponentsBuilder.fromRequest(request).build().getHost());
  }

Affects: 3.2.5

@spring-projects-issues
Copy link
Collaborator Author

Chris Pimlott commented

This issue on another project has an example Apache configuration that generates a multi-valued X-Forwarded-Host header:

xp-framework/xp-framework#162

@spring-projects-issues
Copy link
Collaborator Author

Rossen Stoyanchev commented

This was already working as of 4.0 RC1 as part of changes introducing MvcUriComponentsBuilder. It is now fixed in 3.2.x as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
in: web Issues in web modules (web, webmvc, webflux, websocket) type: bug A general bug
Projects
None yet
Development

No branches or pull requests

2 participants