Commit d34c02cc authored by andersca@apple.com's avatar andersca@apple.com

REGRESSION (r158927): curly-braces-escaping.html is broken on Mac WebKit2

https://bugs.webkit.org/show_bug.cgi?id=124164

Reviewed by Alexey Proskuryakov.

Back out the change to use NSSecureCoding for encoding/decoding NSURLRequest and
NSURLResponse objects; turns out the NSURL encoding/decoding doesn't preserve the raw URL bytes.

* Shared/mac/WebCoreArgumentCodersMac.mm:
(CoreIPC::encodePlatformData):
(CoreIPC::decodePlatformData):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159084 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 2dfecd17
2013-11-11 Anders Carlsson <andersca@apple.com>
REGRESSION (r158927): curly-braces-escaping.html is broken on Mac WebKit2
https://bugs.webkit.org/show_bug.cgi?id=124164
Reviewed by Alexey Proskuryakov.
Back out the change to use NSSecureCoding for encoding/decoding NSURLRequest and
NSURLResponse objects; turns out the NSURL encoding/decoding doesn't preserve the raw URL bytes.
* Shared/mac/WebCoreArgumentCodersMac.mm:
(CoreIPC::encodePlatformData):
(CoreIPC::decodePlatformData):
2013-11-11 Ryuan Choi <ryuan.choi@samsung.com>
Unreviewed build fix on CMake Based port since r159077.
......
......@@ -39,33 +39,6 @@ using namespace WebKit;
namespace CoreIPC {
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
static void archiveAndEncodeObject(ArgumentEncoder& encoder, id object, NSString *key)
{
RetainPtr<NSMutableData> data = adoptNS([[NSMutableData alloc] init]);
RetainPtr<NSKeyedArchiver> archiver = adoptNS([[NSKeyedArchiver alloc] initForWritingWithMutableData:data.get()]);
[archiver setRequiresSecureCoding:YES];
[archiver.get() encodeObject:object forKey:key];
[archiver finishEncoding];
encoder << CoreIPC::DataReference(static_cast<const uint8_t*>([data bytes]), [data length]);
}
template<typename T>
static bool decodeAndUnarchiveObject(ArgumentDecoder& decoder, NSString *key, RetainPtr<T>& result)
{
CoreIPC::DataReference dataReference;
if (!decoder.decode(dataReference))
return false;
RetainPtr<NSData> data = adoptNS([[NSData alloc] initWithBytesNoCopy:const_cast<uint8_t*>(dataReference.data()) length:dataReference.size() freeWhenDone:NO]);
RetainPtr<NSKeyedUnarchiver> unarchiver = adoptNS([[NSKeyedUnarchiver alloc] initForReadingWithData:data.get()]);
[unarchiver setRequiresSecureCoding:YES];
result = [unarchiver decodeObjectOfClass:[T class] forKey:key];
return true;
}
#endif
void ArgumentCoder<ResourceRequest>::encodePlatformData(ArgumentEncoder& encoder, const ResourceRequest& resourceRequest)
{
RetainPtr<NSURLRequest> requestToSerialize = resourceRequest.nsURLRequest(DoNotUpdateHTTPBody);
......@@ -84,12 +57,8 @@ void ArgumentCoder<ResourceRequest>::encodePlatformData(ArgumentEncoder& encoder
[(NSMutableURLRequest *)requestToSerialize setHTTPBodyStream:nil];
}
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
archiveAndEncodeObject(encoder, requestToSerialize.get(), @"request");
#else
RetainPtr<CFDictionaryRef> dictionary = adoptCF(WKNSURLRequestCreateSerializableRepresentation(requestToSerialize.get(), CoreIPC::tokenNullTypeRef()));
CoreIPC::encode(encoder, dictionary.get());
#endif
// The fallback array is part of NSURLRequest, but it is not encoded by WKNSURLRequestCreateSerializableRepresentation.
encoder << resourceRequest.responseContentDispositionEncodingFallbackArray();
......@@ -106,11 +75,6 @@ bool ArgumentCoder<ResourceRequest>::decodePlatformData(ArgumentDecoder& decoder
return true;
}
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
RetainPtr<NSURLRequest> nsURLRequest;
if (!decodeAndUnarchiveObject(decoder, @"request", nsURLRequest))
return false;
#else
RetainPtr<CFDictionaryRef> dictionary;
if (!CoreIPC::decode(decoder, dictionary))
return false;
......@@ -118,7 +82,6 @@ bool ArgumentCoder<ResourceRequest>::decodePlatformData(ArgumentDecoder& decoder
RetainPtr<NSURLRequest> nsURLRequest = WKNSURLRequestFromSerializableRepresentation(dictionary.get(), CoreIPC::tokenNullTypeRef());
if (!nsURLRequest)
return false;
#endif
resourceRequest = ResourceRequest(nsURLRequest.get());
......@@ -143,12 +106,8 @@ void ArgumentCoder<ResourceResponse>::encodePlatformData(ArgumentEncoder& encode
if (!responseIsPresent)
return;
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
archiveAndEncodeObject(encoder, resourceResponse.nsURLResponse(), @"response");
#else
RetainPtr<CFDictionaryRef> dictionary = adoptCF(WKNSURLResponseCreateSerializableRepresentation(resourceResponse.nsURLResponse(), CoreIPC::tokenNullTypeRef()));
CoreIPC::encode(encoder, dictionary.get());
#endif
}
bool ArgumentCoder<ResourceResponse>::decodePlatformData(ArgumentDecoder& decoder, ResourceResponse& resourceResponse)
......@@ -162,17 +121,11 @@ bool ArgumentCoder<ResourceResponse>::decodePlatformData(ArgumentDecoder& decode
return true;
}
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1090
RetainPtr<NSURLResponse> nsURLResponse;
if (!decodeAndUnarchiveObject(decoder, @"response", nsURLResponse))
return false;
#else
RetainPtr<CFDictionaryRef> dictionary;
if (!CoreIPC::decode(decoder, dictionary))
return false;
RetainPtr<NSURLResponse> nsURLResponse = WKNSURLResponseFromSerializableRepresentation(dictionary.get(), CoreIPC::tokenNullTypeRef());
#endif
if (!nsURLResponse)
return false;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment