mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 658949 patch 1: Teach nsDataHandler::ParseURI about #ref, and transfer 'isRefValid' flag in nsSimpleURI::Clone. r=bz
This commit is contained in:
parent
2d246fbdb2
commit
9c8854da80
@ -115,8 +115,10 @@ nsSimpleURI::Read(nsIObjectInputStream* aStream)
|
||||
mIsRefValid = isRefValid;
|
||||
|
||||
if (isRefValid) {
|
||||
rv = aStream->ReadCString(mRef);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
rv = aStream->ReadCString(mRef);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
} else {
|
||||
mRef.Truncate(); // invariant: mRef should be empty when it's not valid
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
@ -166,6 +168,7 @@ nsSimpleURI::Read(const IPC::Message *aMsg, void **aIter)
|
||||
if (mIsRefValid) {
|
||||
return ReadParam(aMsg, aIter, &mRef);
|
||||
}
|
||||
mRef.Truncate(); // invariant: mRef should be empty when it's not valid
|
||||
|
||||
return PR_TRUE;
|
||||
}
|
||||
@ -191,6 +194,8 @@ nsSimpleURI::GetSpec(nsACString &result)
|
||||
result = mScheme + NS_LITERAL_CSTRING(":") + mPath;
|
||||
if (mIsRefValid) {
|
||||
result += NS_LITERAL_CSTRING("#") + mRef;
|
||||
} else {
|
||||
NS_ABORT_IF_FALSE(mRef.IsEmpty(), "mIsRefValid/mRef invariant broken");
|
||||
}
|
||||
return NS_OK;
|
||||
}
|
||||
@ -368,6 +373,7 @@ nsSimpleURI::SetPath(const nsACString &path)
|
||||
PRInt32 hashPos = path.FindChar('#');
|
||||
if (hashPos < 0) {
|
||||
mIsRefValid = PR_FALSE;
|
||||
mRef.Truncate(); // invariant: mRef should be empty when it's not valid
|
||||
mPath = path;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -380,6 +386,7 @@ NS_IMETHODIMP
|
||||
nsSimpleURI::GetRef(nsACString &result)
|
||||
{
|
||||
if (!mIsRefValid) {
|
||||
NS_ABORT_IF_FALSE(mRef.IsEmpty(), "mIsRefValid/mRef invariant broken");
|
||||
result.Truncate();
|
||||
} else {
|
||||
result = mRef;
|
||||
@ -398,7 +405,7 @@ nsSimpleURI::SetRef(const nsACString &aRef)
|
||||
if (aRef.IsEmpty()) {
|
||||
// Empty string means to remove ref completely.
|
||||
mIsRefValid = PR_FALSE;
|
||||
mRef.Truncate();
|
||||
mRef.Truncate(); // invariant: mRef should be empty when it's not valid
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -503,6 +510,7 @@ nsSimpleURI::CloneInternal(nsSimpleURI::RefHandlingEnum refHandlingMode,
|
||||
url->mPath = mPath;
|
||||
if (refHandlingMode == eHonorRef) {
|
||||
url->mRef = mRef;
|
||||
url->mIsRefValid = mIsRefValid;
|
||||
}
|
||||
|
||||
url.forget(result);
|
||||
|
@ -62,10 +62,10 @@ nsDataChannel::OpenContentStream(PRBool async, nsIInputStream **result,
|
||||
rv = URI()->GetAsciiSpec(spec);
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
||||
nsCString contentType, contentCharset, dataBuffer;
|
||||
nsCString contentType, contentCharset, dataBuffer, hashRef;
|
||||
PRBool lBase64;
|
||||
rv = nsDataHandler::ParseURI(spec, contentType, contentCharset,
|
||||
lBase64, dataBuffer);
|
||||
lBase64, dataBuffer, hashRef);
|
||||
|
||||
NS_UnescapeURL(dataBuffer);
|
||||
|
||||
|
@ -114,9 +114,9 @@ nsDataHandler::NewURI(const nsACString &aSpec,
|
||||
rv = uri->SetRef(spec);
|
||||
} else {
|
||||
// Otherwise, we'll assume |spec| is a fully-specified data URI
|
||||
nsCAutoString contentType, contentCharset, dataBuffer;
|
||||
nsCAutoString contentType, contentCharset, dataBuffer, hashRef;
|
||||
PRBool base64;
|
||||
rv = ParseURI(spec, contentType, contentCharset, base64, dataBuffer);
|
||||
rv = ParseURI(spec, contentType, contentCharset, base64, dataBuffer, hashRef);
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
@ -171,7 +171,8 @@ nsDataHandler::ParseURI(nsCString& spec,
|
||||
nsCString& contentType,
|
||||
nsCString& contentCharset,
|
||||
PRBool& isBase64,
|
||||
nsCString& dataBuffer) {
|
||||
nsCString& dataBuffer,
|
||||
nsCString& hashRef) {
|
||||
isBase64 = PR_FALSE;
|
||||
|
||||
// move past "data:"
|
||||
@ -230,7 +231,16 @@ nsDataHandler::ParseURI(nsCString& spec,
|
||||
contentType.StripWhitespace();
|
||||
contentCharset.StripWhitespace();
|
||||
|
||||
dataBuffer.Assign(comma + 1);
|
||||
// Split encoded data from terminal "#ref" (if present)
|
||||
char *data = comma + 1;
|
||||
char *hash = strchr(data, '#');
|
||||
if (!hash) {
|
||||
dataBuffer.Assign(data);
|
||||
hashRef.Truncate();
|
||||
} else {
|
||||
dataBuffer.Assign(data, hash - data);
|
||||
hashRef.Assign(hash);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -63,7 +63,8 @@ public:
|
||||
nsCString& contentType,
|
||||
nsCString& contentCharset,
|
||||
PRBool& isBase64,
|
||||
nsCString& dataBuffer);
|
||||
nsCString& dataBuffer,
|
||||
nsCString& hashRef);
|
||||
};
|
||||
|
||||
#endif /* nsDataHandler_h___ */
|
||||
|
Loading…
Reference in New Issue
Block a user