Issue Details (XML | Word | Printable)

Key: JETTY-438
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Greg Wilkins
Reporter: Eirik Bjørsnøs
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Jetty

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

Created: 10/Oct/07 07:45 AM   Updated: 28/Oct/07 08:28 PM
Component/s: HTTP
Affects Version/s: 6.1.5
Fix Version/s: 6.1.6rc1

Time Tracking:
Not Specified

File Attachments: 1. Text File JETTY-438-host-normalization-patch.txt (7 kB)

Environment: Mac OS X / java version "1.5.0_07"


 Description  « Hide

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



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Eirik Bjørsnøs added a comment - 10/Oct/07 08:09 AM
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.

Greg Wilkins added a comment - 28/Oct/07 08:28 PM
Patch applied (with small reformat)

thanks for the good patch with test harness!