Bug 682845: Update IIDs, fix serializations of nsStandardURL broken by bug 665706 r/sr=bz
authorRandell Jesup <rjesup@wgate.com>
Sat, 10 Sep 2011 05:27:29 -0400
changeset 76869 c5ed260e9a49f44f2286e0231bf4f6ffaec85535
parent 76868 01256254361ba8c64823371620b9024c3df7005a
child 76870 d069439624f53f01c6438687ff4a261a802167a7
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
bugs682845, 665706
milestone9.0a1
Bug 682845: Update IIDs, fix serializations of nsStandardURL broken by bug 665706 r/sr=bz
modules/libjar/nsIJARURI.idl
netwerk/base/public/nsIFileURL.idl
netwerk/base/public/nsIURL.idl
netwerk/base/public/nsIURLParser.idl
netwerk/base/src/nsStandardURL.cpp
netwerk/base/src/nsStandardURL.h
--- a/modules/libjar/nsIJARURI.idl
+++ b/modules/libjar/nsIJARURI.idl
@@ -42,17 +42,17 @@
  * JAR URLs have the following syntax
  *
  * jar:<jar-file-uri>!/<jar-entry>
  *
  * EXAMPLE: jar:http://www.big.com/blue.jar!/ocean.html
  *
  * The nsIURL methods operate on the <jar-entry> part of the spec.
  */
-[scriptable, uuid(0d31634e-2fc9-4597-9d53-11fb3f05516a)]
+[scriptable, uuid(1ee60719-c056-43b3-8f54-6a6e7ba0ca6c)]
 interface nsIJARURI : nsIURL {
 
     /**
      * Returns the root URI (the one for the actual JAR file) for this JAR
      * (e.g., http://www.big.com/blue.jar).
      */
     readonly attribute nsIURI JARFile;
 
--- a/netwerk/base/public/nsIFileURL.idl
+++ b/netwerk/base/public/nsIFileURL.idl
@@ -40,17 +40,17 @@
 
 interface nsIFile;
 
 /**
  * nsIFileURL provides access to the underlying nsIFile object corresponding to
  * an URL.  The URL scheme need not be file:, since other local protocols may
  * map URLs to files (e.g., resource:).
  */
-[scriptable, uuid(93a4f94e-1dae-4056-ac4e-08e13691ee8e)]
+[scriptable, uuid(7750029c-1b0a-414e-8359-a77f24a2a0a6)]
 interface nsIFileURL : nsIURL
 {
     /**
      * Get/Set nsIFile corresponding to this URL.
      *
      *  - Getter returns a reference to an immutable object.  Callers must clone
      *    before attempting to modify the returned nsIFile object.  NOTE: this
      *    constraint might not be enforced at runtime, so beware!!
--- a/netwerk/base/public/nsIURL.idl
+++ b/netwerk/base/public/nsIURL.idl
@@ -48,17 +48,17 @@
  *            \          \                       /
  *             \          -----------------------
  *              \                   |          /
  *               \               fileName     /
  *                ----------------------------
  *                            |
  *                        filePath
  */
-[scriptable, uuid(067d697a-c725-4293-9656-e658a75e6bcf)]
+[scriptable, uuid(1419aa16-f134-4154-9886-00c7c5147a13)]
 interface nsIURL : nsIURI
 {
     /*************************************************************************
      * The URL path is broken down into the following principal components:
      */
 
     /**
      * Returns a path including the directory and file portions of a
--- a/netwerk/base/public/nsIURLParser.idl
+++ b/netwerk/base/public/nsIURLParser.idl
@@ -37,17 +37,17 @@
  * ***** END LICENSE BLOCK ***** */
 
 #include "nsISupports.idl"
 
 /**
  * nsIURLParser specifies the interface to an URL parser that attempts to
  * follow the definitions of RFC 2396.
  */
-[scriptable, uuid(7281076d-cf37-464a-815e-698235802604)]
+[scriptable, uuid(78c5d19f-f5d2-4732-8d3d-d5a7d7133bc0)]
 interface nsIURLParser : nsISupports
 {
     /**
      * The string to parse in the following methods may be given as a null
      * terminated string, in which case the length argument should be -1.
      *
      * Out parameters of the following methods are all optional (ie. the caller
      * may pass-in a NULL value if the corresponding results are not needed).
--- a/netwerk/base/src/nsStandardURL.cpp
+++ b/netwerk/base/src/nsStandardURL.cpp
@@ -2766,16 +2766,21 @@ nsStandardURL::Read(nsIObjectInputStream
     if (NS_FAILED(rv)) return rv;
 
     rv = ReadSegment(stream, mBasename);
     if (NS_FAILED(rv)) return rv;
 
     rv = ReadSegment(stream, mExtension);
     if (NS_FAILED(rv)) return rv;
 
+    // handle forward compatibility from older serializations that included mParam
+    URLSegment old_param;
+    rv = ReadSegment(stream, old_param);
+    if (NS_FAILED(rv)) return rv;
+
     rv = ReadSegment(stream, mQuery);
     if (NS_FAILED(rv)) return rv;
 
     rv = ReadSegment(stream, mRef);
     if (NS_FAILED(rv)) return rv;
 
     rv = NS_ReadOptionalCString(stream, mOriginCharset);
     if (NS_FAILED(rv)) return rv;
@@ -2801,16 +2806,28 @@ nsStandardURL::Read(nsIObjectInputStream
     PRUint32 hostEncoding;
     rv = stream->Read32(&hostEncoding);
     if (NS_FAILED(rv)) return rv;
     if (hostEncoding != eEncoding_ASCII && hostEncoding != eEncoding_UTF8) {
         NS_WARNING("Unexpected host encoding");
         return NS_ERROR_UNEXPECTED;
     }
     mHostEncoding = hostEncoding;
+
+    // wait until object is set up, then modify path to include the param
+    if (old_param.mLen >= 0) {  // note that mLen=0 is ";"
+        // If this wasn't empty, it marks characters between the end of the 
+        // file and start of the query - mPath should include the param,
+        // query and ref already.  Bump the mFilePath and 
+        // directory/basename/extension components to include this.
+        mFilepath.Merge(mSpec,  ';', old_param);
+        mDirectory.Merge(mSpec, ';', old_param);
+        mBasename.Merge(mSpec,  ';', old_param);
+        mExtension.Merge(mSpec, ';', old_param);
+    }
     
     return NS_OK;
 }
 
 NS_IMETHODIMP
 nsStandardURL::Write(nsIObjectOutputStream *stream)
 {
     nsresult rv;
@@ -2852,16 +2869,24 @@ nsStandardURL::Write(nsIObjectOutputStre
     if (NS_FAILED(rv)) return rv;
 
     rv = WriteSegment(stream, mBasename);
     if (NS_FAILED(rv)) return rv;
 
     rv = WriteSegment(stream, mExtension);
     if (NS_FAILED(rv)) return rv;
 
+    // for backwards compatibility since we removed mParam.  Note that this will mean that
+    // an older browser will read "" for mParam, and the param(s) will be part of mPath (as they
+    // after the removal of special handling).  It only matters if you downgrade a browser to before
+    // the patch.
+    URLSegment empty;
+    rv = WriteSegment(stream, empty);
+    if (NS_FAILED(rv)) return rv;
+
     rv = WriteSegment(stream, mQuery);
     if (NS_FAILED(rv)) return rv;
 
     rv = WriteSegment(stream, mRef);
     if (NS_FAILED(rv)) return rv;
 
     rv = NS_WriteOptionalStringZ(stream, mOriginCharset.get());
     if (NS_FAILED(rv)) return rv;
--- a/netwerk/base/src/nsStandardURL.h
+++ b/netwerk/base/src/nsStandardURL.h
@@ -100,16 +100,27 @@ public: /* internal -- HPUX compiler can
     struct URLSegment
     {
         PRUint32 mPos;
         PRInt32  mLen;
 
         URLSegment() : mPos(0), mLen(-1) {}
         URLSegment(PRUint32 pos, PRInt32 len) : mPos(pos), mLen(len) {}
         void Reset() { mPos = 0; mLen = -1; }
+        // Merge another segment following this one to it if they're contiguous
+        // Assumes we have something like "foo;bar" where this object is 'foo' and right
+        // is 'bar'.
+        void Merge(const nsCString &spec, const char separator, const URLSegment &right) {
+            if (mLen >= 0 && 
+                *(spec.get() + mPos + mLen) == separator &&
+                mPos + mLen + 1 == right.mPos) {
+                mLen += 1 + right.mLen;
+            }
+        }
+            
     };
 
     //
     // Pref observer
     //
     class nsPrefObserver : public nsIObserver
     {
     public: