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 217398 9306dcf4eb398c6448c1e014ad944717de2cd10f
parent 217397 4c6fff1b12002197aef1ed77d3c0c147c9b37574
child 217399 7ca858f394476c7c8600f4e5eea76ace137d7cf5
push id515
push userraliiev@mozilla.com
push dateMon, 06 Oct 2014 12:51:51 +0000
treeherdermozilla-release@267c7a481bef [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmcmanus, sledru
bugs1035007
milestone33.0a2
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);