Open Bug 559469 Opened 15 years ago Updated 2 years ago

Weird results from giving ":" as a hostname

Categories

(Core :: Networking, defect, P3)

defect

Tracking

()

People

(Reporter: usenet, Unassigned)

References

()

Details

(Whiteboard: [necko-backlog])

While checking out Bug 554596 for edge cases, I thought I'd take a look at IPv6-encapsulated IPv4 addresses. I've come up with this test case: http://: Putting it in the Firefox URL bar causes Firefox to rewrite it as http://[www.:.com]/ and give the error message "Server not found. Firefox can't find the server at www.:.com." Firefox seems to be confused as to whether ":" is a hostname, or an IPv6 address -- either way, the result is wrong, and indicative of a confused code path that may have other issues.
Note that the "http://:" in the comment above is not clickable: this is because Bugzilla has not recognized the whole thing, autolinking instead only to "http://"
URI fixup just takes the reported host from the original URI (which is ":"), makes it into "www.:.com" and calls nsStandardURL::SetHost. SetHost calls nsStandardURL::EscapeIPv6, which is: 397 nsStandardURL::EscapeIPv6(const char *host, nsCString &result) 398 { 399 // Escape IPv6 address literal by surrounding it with []'s 400 if (host && (host[0] != '[') && PL_strchr(host, ':')) { 401 result.Assign('['); 402 result.Append(host); 403 result.Append(']'); 404 return PR_TRUE; 405 } This is the only caller of EscapeIPv6, which is why the original URI didn't end up as http://[:]. I suppose EscapeIPv6 could do more vetting, but is there a serious problem with the current behavior? Or more precisely, is there a problem with putting '[' and ']' around any string passed to SetHost that contains ':'?
Whiteboard: [necko-backlog]
Priority: -- → P1
Priority: P1 → P3
Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.