Bug 464162 - Apache does not accept IPv6 addresses with a scope id in the Host: header; r+sr=cbiesinger
authorMasahiro Yamada <masa141421356@gmail.com>
Sat, 06 Dec 2008 14:15:24 +0100
changeset 22421 bb80e727c531463655f75ceef45ca3d09932448e
parent 22420 f3663178d2e25d3587bb6690cd2491c870a82f07
child 22423 c9d7a1d3f4138c21e99ab048a114e0e9ef0baf00
push id3976
push usersgautherie.bz@free.fr
push dateSat, 06 Dec 2008 13:15:50 +0000
treeherdermozilla-central@bb80e727c531 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs464162
milestone1.9.2a1pre
Bug 464162 - Apache does not accept IPv6 addresses with a scope id in the Host: header; r+sr=cbiesinger
netwerk/protocol/http/src/nsHttpChannel.cpp
--- a/netwerk/protocol/http/src/nsHttpChannel.cpp
+++ b/netwerk/protocol/http/src/nsHttpChannel.cpp
@@ -217,17 +217,24 @@ nsHttpChannel::Init(nsIURI *uri,
 
     //
     // Set request headers
     //
     nsCAutoString hostLine;
     if (strchr(host.get(), ':')) {
         // host is an IPv6 address literal and must be encapsulated in []'s
         hostLine.Assign('[');
-        hostLine.Append(host);
+        // scope id is not needed for Host header.
+        int scopeIdPos = host.FindChar('%');
+        if (scopeIdPos == kNotFound)
+            hostLine.Append(host);
+        else if (scopeIdPos > 0)
+            hostLine.Append(Substring(host, 0, scopeIdPos));
+        else
+          return NS_ERROR_MALFORMED_URI;
         hostLine.Append(']');
     }
     else
         hostLine.Assign(host);
     if (port != -1) {
         hostLine.Append(':');
         hostLine.AppendInt(port);
     }