Bug 1035007 - Make sure hostname is inserted in the right place. r=mcmanus, a=sledru
authorValentin Gosu <valentin.gosu@gmail.com>
Wed, 06 Aug 2014 08:17:53 -0400
changeset 208252 e6cee3b7907e
parent 208251 4da65dc7d057
child 208253 8f34703f5065
push id3790
push userryanvm@gmail.com
push date2014-08-07 15:21 +0000
treeherdermozilla-beta@ee74d30a8968 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus, sledru
bugs1035007
milestone32.0
Bug 1035007 - Make sure hostname is inserted in the right place. r=mcmanus, a=sledru
netwerk/base/src/nsStandardURL.cpp
--- a/netwerk/base/src/nsStandardURL.cpp
+++ b/netwerk/base/src/nsStandardURL.cpp
@@ -1564,18 +1564,23 @@ nsStandardURL::SetHost(const nsACString 
     if (mHost.mLen < 0) {
         int port_length = 0;
         if (mPort != -1) {
             nsAutoCString buf;
             buf.Assign(':');
             buf.AppendInt(mPort);
             port_length = buf.Length();
         }
-        mHost.mPos = mAuthority.mPos + mAuthority.mLen - port_length;
-        mHost.mLen = 0;
+        if (mAuthority.mLen > 0) {
+            mHost.mPos = mAuthority.mPos + mAuthority.mLen - port_length;
+            mHost.mLen = 0;
+        } else if (mScheme.mLen > 0) {
+            mHost.mPos = mScheme.mPos + mScheme.mLen + 3;
+            mHost.mLen = 0;
+        }
     }
 
     int32_t shift = ReplaceSegment(mHost.mPos, mHost.mLen, host, len);
 
     if (shift) {
         mHost.mLen = len;
         mAuthority.mLen += shift;
         ShiftFromPath(shift);
@@ -1655,17 +1660,16 @@ nsStandardURL::SetPort(int32_t port)
 }
 
 NS_IMETHODIMP
 nsStandardURL::SetPath(const nsACString &input)
 {
     ENSURE_MUTABLE();
 
     const nsPromiseFlatCString &path = PromiseFlatCString(input);
-
     LOG(("nsStandardURL::SetPath [path=%s]\n", path.get()));
 
     InvalidateCache();
 
     if (!path.IsEmpty()) {
         nsAutoCString spec;
 
         spec.Assign(mSpec.get(), mPath.mPos);