Changeset 184026 in webkit


Ignore:
Timestamp:
May 8, 2015 4:13:36 PM (9 years ago)
Author:
mitz@apple.com
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.

Location:
trunk/Source/WebKit2
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit2/ChangeLog

    r184024 r184026  
     12015-05-08  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/20757196> NSInternalInconsistencyException raised in -[NSString encodeWithCoder:] beneath createEncodedObject when using WKRemoteObjectEncoder for Safari AutoFill
     4        https://bugs.webkit.org/show_bug.cgi?id=144818
     5
     6        Reviewed by Anders Carlsson.
     7
     8        Allow NSString instances that contain unpaired surrogates to be encoded by
     9        WKRemoteObjectCoder by encoding them directly rather than using
     10        -[NSString encodeWithCoder:].
     11
     12        * Shared/API/Cocoa/WKRemoteObjectCoder.mm:
     13        (encodeString): Added. Sets an API::String as the object to encode.
     14        (encodeObject): Changed to use encodeString for NSString instances.
     15        (decodeString): Added. Gets an API::String from the dictionary and returns it as an
     16        NSString.
     17        (decodeObject): Changed to use decodeString for NSString instances.
     18
    1192015-05-08  Timothy Horton  <timothy_horton@apple.com>
    220
  • trunk/Source/WebKit2/Shared/API/Cocoa/WKRemoteObjectCoder.mm

    r183412 r184026  
    4242static const char* const classNameKey = "$class";
    4343static const char* const objectStreamKey = "$objectStream";
     44static const char* const stringKey = "$string";
    4445
    4546static NSString * const selectorKey = @"selector";
     
    212213        }
    213214    }
     215}
     216
     217static void encodeString(WKRemoteObjectEncoder *encoder, NSString *string)
     218{
     219    encoder->_currentDictionary->set(stringKey, API::String::create(string));
    214220}
    215221
     
    236242    }
    237243
     244    if ([object isKindOfClass:[NSString class]]) {
     245        encodeString(encoder, object);
     246        return;
     247    }
     248
    238249    [object encodeWithCoder:encoder];
    239250}
     
    547558}
    548559
     560static NSString *decodeString(WKRemoteObjectDecoder *decoder)
     561{
     562    API::String* string = decoder->_currentDictionary->get<API::String>(stringKey);
     563    if (!string)
     564        [NSException raise:NSInvalidUnarchiveOperationException format:@"String missing"];
     565
     566    return string->string();
     567}
     568
    549569static id decodeObject(WKRemoteObjectDecoder *decoder)
    550570{
     
    563583    if (objectClass == [NSInvocation class])
    564584        return decodeInvocation(decoder);
     585
     586    if (objectClass == [NSString class])
     587        return decodeString(decoder);
    565588
    566589    id result = [objectClass allocWithZone:decoder.zone];
Note: See TracChangeset for help on using the changeset viewer.