Jetty

Trailing dot not considered while looking up virtual hosts "www.example.com" and "www.example.com."

Details

  • Type: Bug Bug
  • Status: Resolved Resolved
  • Priority: Major Major
  • Resolution: Fixed
  • Affects Version/s: 6.1.5
  • Fix Version/s: 6.1.6rc1
  • Component/s: HTTP
  • Labels:
    None
  • Environment:
    Mac OS X / java version "1.5.0_07"
  • Number of attachments :
    1

Description

Reading RFC1034 [1], my interpretation is that domain names with or without a trailing dot should be treated the same.

That is, these two addresses should give the same response:

www.example.com
www.example.com.

Virtual hosting in Jetty does not take this into consideration since the comparison between request.getServerName() and the virtual host names is done with a simple equalsIgnoreCase(). (See ContextHandler line 618).

Looking at other web server implementations I see that Tomcat will treat these addresses as different (similar to Jetty), while Apache Httpd will treat them as the same.

I have a feeling that Apache Httpd has the correct and least surprising behavior in this case.

[1] http://www.ietf.org/rfc/rfc1034.txt

Activity

Hide
Eirik Bjørsnøs added a comment -

Added pacth that:

  • Adds the private method normalizeHostname to ContextHandler. This method will remove any trailing dot from a host name
  • Updates ContextHandler's setVirtualHosts() to use normalizeHostname on host names
  • Updates ContextHandler's handle() method to use normalizeHostname to normalize request.getServerName()
  • Adds a test to ContextHanderTest that tests request to "www.example.com." with vhost "www.example.com" and vice versa.
Show
Eirik Bjørsnøs added a comment - Added pacth that:
  • Adds the private method normalizeHostname to ContextHandler. This method will remove any trailing dot from a host name
  • Updates ContextHandler's setVirtualHosts() to use normalizeHostname on host names
  • Updates ContextHandler's handle() method to use normalizeHostname to normalize request.getServerName()
  • Adds a test to ContextHanderTest that tests request to "www.example.com." with vhost "www.example.com" and vice versa.
Hide
Greg Wilkins added a comment -

Patch applied (with small reformat)

thanks for the good patch with test harness!

Show
Greg Wilkins added a comment - Patch applied (with small reformat) thanks for the good patch with test harness!

People

Vote (0)
Watch (0)

Dates

  • Created:
    Updated:
    Resolved: