Title: [184026] trunk/Source/WebKit2
- Revision
- 184026
- Author
- [email protected]
- Date
- 2015-05-08 16:13:36 -0700 (Fri, 08 May 2015)
Log Message
<rdar://problem/20757196> NSInternalInconsistencyException raised in -[NSString encodeWithCoder:] beneath createEncodedObject when using WKRemoteObjectEncoder for Safari AutoFill
https://bugs.webkit.org/show_bug.cgi?id=144818
Reviewed by Anders Carlsson.
Allow NSString instances that contain unpaired surrogates to be encoded by
WKRemoteObjectCoder by encoding them directly rather than using
-[NSString encodeWithCoder:].
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
(encodeString): Added. Sets an API::String as the object to encode.
(encodeObject): Changed to use encodeString for NSString instances.
(decodeString): Added. Gets an API::String from the dictionary and returns it as an
NSString.
(decodeObject): Changed to use decodeString for NSString instances.
Modified Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (184025 => 184026)
--- trunk/Source/WebKit2/ChangeLog 2015-05-08 23:13:13 UTC (rev 184025)
+++ trunk/Source/WebKit2/ChangeLog 2015-05-08 23:13:36 UTC (rev 184026)
@@ -1,3 +1,21 @@
+2015-05-08 Dan Bernstein <[email protected]>
+
+ <rdar://problem/20757196> NSInternalInconsistencyException raised in -[NSString encodeWithCoder:] beneath createEncodedObject when using WKRemoteObjectEncoder for Safari AutoFill
+ https://bugs.webkit.org/show_bug.cgi?id=144818
+
+ Reviewed by Anders Carlsson.
+
+ Allow NSString instances that contain unpaired surrogates to be encoded by
+ WKRemoteObjectCoder by encoding them directly rather than using
+ -[NSString encodeWithCoder:].
+
+ * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
+ (encodeString): Added. Sets an API::String as the object to encode.
+ (encodeObject): Changed to use encodeString for NSString instances.
+ (decodeString): Added. Gets an API::String from the dictionary and returns it as an
+ NSString.
+ (decodeObject): Changed to use decodeString for NSString instances.
+
2015-05-08 Timothy Horton <[email protected]>
Fix the build.
Modified: trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm (184025 => 184026)
--- trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm 2015-05-08 23:13:13 UTC (rev 184025)
+++ trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm 2015-05-08 23:13:36 UTC (rev 184026)
@@ -41,6 +41,7 @@
static const char* const classNameKey = "$class";
static const char* const objectStreamKey = "$objectStream";
+static const char* const stringKey = "$string";
static NSString * const selectorKey = @"selector";
static NSString * const typeStringKey = @"typeString";
@@ -213,6 +214,11 @@
}
}
+static void encodeString(WKRemoteObjectEncoder *encoder, NSString *string)
+{
+ encoder->_currentDictionary->set(stringKey, API::String::create(string));
+}
+
static void encodeObject(WKRemoteObjectEncoder *encoder, id object)
{
ASSERT(object);
@@ -235,6 +241,11 @@
return;
}
+ if ([object isKindOfClass:[NSString class]]) {
+ encodeString(encoder, object);
+ return;
+ }
+
[object encodeWithCoder:encoder];
}
@@ -546,6 +557,15 @@
return invocation;
}
+static NSString *decodeString(WKRemoteObjectDecoder *decoder)
+{
+ API::String* string = decoder->_currentDictionary->get<API::String>(stringKey);
+ if (!string)
+ [NSException raise:NSInvalidUnarchiveOperationException format:@"String missing"];
+
+ return string->string();
+}
+
static id decodeObject(WKRemoteObjectDecoder *decoder)
{
API::String* classNameString = decoder->_currentDictionary->get<API::String>(classNameKey);
@@ -563,6 +583,9 @@
if (objectClass == [NSInvocation class])
return decodeInvocation(decoder);
+ if (objectClass == [NSString class])
+ return decodeString(decoder);
+
id result = [objectClass allocWithZone:decoder.zone];
if (!result)
[NSException raise:NSInvalidUnarchiveOperationException format:@"Class \"%s\" returned nil from +alloc while being decoded", className.data()];
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes