Bug 682845: Update IIDs, fix serializations of nsStandardURL broken by bug 665706 r/sr=bz

This commit is contained in:
Randell Jesup 2011-09-10 05:27:29 -04:00
parent 0e8600cbfa
commit 2cff549103
6 changed files with 40 additions and 4 deletions

View File

@ -47,7 +47,7 @@
*
* 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 {
/**

View File

@ -45,7 +45,7 @@ interface nsIFile;
* 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
{
/**

View File

@ -53,7 +53,7 @@
* |
* filePath
*/
[scriptable, uuid(067d697a-c725-4293-9656-e658a75e6bcf)]
[scriptable, uuid(1419aa16-f134-4154-9886-00c7c5147a13)]
interface nsIURL : nsIURI
{
/*************************************************************************

View File

@ -42,7 +42,7 @@
* 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
{
/**

View File

@ -2771,6 +2771,11 @@ nsStandardURL::Read(nsIObjectInputStream *stream)
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;
@ -2806,6 +2811,18 @@ nsStandardURL::Read(nsIObjectInputStream *stream)
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;
}
@ -2857,6 +2874,14 @@ nsStandardURL::Write(nsIObjectOutputStream *stream)
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;

View File

@ -105,6 +105,17 @@ public: /* internal -- HPUX compiler can't handle this being private */
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;
}
}
};
//