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 22183 f9b9392580e2ac0e42266dee46cf613aeac523a8
parent 22182 c07d033ee085d2f6663eeccf99fc30263965893c
child 22184 770b8eaaec95b7d937e6154c76a39bc60e01379c
push id89
push userdgottwald@mozilla.com
push dateSun, 07 Dec 2008 14:45:52 +0000
bugs464162
milestone1.9.1b3pre
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);
     }