Changeset 226224 in webkit
- Timestamp:
- Dec 21, 2017 9:18:31 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r226221 r226224 1 2017-12-21 Brent Fulgham <bfulgham@apple.com> 2 3 Adopt new secure coding APIs in WebCore 4 https://bugs.webkit.org/show_bug.cgi?id=178484 5 <rdar://problem/34837193> 6 7 Reviewed by Eric Carlson. 8 9 Switch to new NSKeyed[Un]Archiver methods that use NSSecureCoding by default. 10 11 Most of the new API is wrapped in a set of convenience methods so we can 12 build without the new API on older systems. 13 14 No change in behavior. 15 16 * editing/cocoa/EditorCocoa.mm: 17 (WebCore::archivedDataForAttributedString): Use new convenience method 18 to archive the string object. 19 * platform/ios/PlatformPasteboardIOS.mm: 20 (WebCore::PlatformPasteboard::write): Use new secure API. 21 (WebCore::PlatformPasteboard::typesSafeForDOMToReadAndWrite const): Ditto. 22 1 23 2017-12-21 Zalan Bujtas <zalan@apple.com> 2 24 -
trunk/Source/WebCore/PAL/ChangeLog
r226218 r226224 1 2017-12-21 Brent Fulgham <bfulgham@apple.com> 2 3 Adopt new secure coding APIs in WebCore 4 https://bugs.webkit.org/show_bug.cgi?id=178484 5 <rdar://problem/34837193> 6 7 Reviewed by Eric Carlson. 8 9 Due to <rdar://problem/31376830 we cannot used SecureCoding on NSAttributedString 10 in some cases. Add a macro for OS revisions that do not support secure coding, 11 and use the standard unarchive operation for NSAttributedString in those cases. 12 13 Rename 'insecurelyUnarchiveObjectOfClassFromData' to 'insecurelyUnarchiveObjectFromData', 14 and move it earlier in the file so that it can be reused in 'unarchivedObjectOfClassFromData'. 15 16 * pal/spi/cocoa/NSKeyedArchiverSPI.h: 17 (insecurelyUnarchiveObjectFromData): Renamed from insecurelyUnarchiveObjectOfClassFromData. 18 (unarchivedObjectOfClassFromData): Renamed from 'securelyUnarchiveObjectOfClassFromData' and 19 modified to use 'insecurelyUnarchiveObjectFromData'. 20 (securelyUnarchiveObjectOfClassFromData): Deleted. 21 (insecurelyUnarchiveObjectOfClassFromData): Deleted. 22 1 23 2017-12-21 Jeremy Jones <jeremyj@apple.com> 2 24 -
trunk/Source/WebCore/PAL/pal/spi/cocoa/NSKeyedArchiverSPI.h
r225309 r226224 31 31 32 32 #define USE_SECURE_ARCHIVER_API ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101302 && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 110200) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 40200) || (PLATFORM(TVOS) && __TV_OS_VERSION_MIN_REQUIRED >= 110200)) 33 34 #define USE_SECURE_ARCHIVER_FOR_ATTRIBUTED_STRING ((PLATFORM(MAC) && __MAC_OS_X_VERSION_MAX_ALLOWED >= 101302 && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101300) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 120000) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 50000) || (PLATFORM(TVOS) && __TV_OS_VERSION_MIN_REQUIRED >= 120000)) 33 35 34 36 #if USE(SECURE_ARCHIVER_API) … … 83 85 } 84 86 85 inline id _Nullable securelyUnarchiveObjectOfClassFromData(Class _Nonnull cls, NSData * _Nonnull data) 86 { 87 #if USE(SECURE_ARCHIVER_API) 88 NSError *error; 89 id value = [NSKeyedUnarchiver unarchivedObjectOfClass:cls fromData:data error:&error]; 90 if (!data) 91 LOG_ERROR("Unable to unarchive data: %@", error); 92 return value; 93 #else 94 UNUSED_PARAM(cls); 95 return [NSKeyedUnarchiver unarchiveObjectWithData:data]; 96 #endif 97 } 98 99 inline id _Nullable insecurelyUnarchiveObjectOfClassFromData(NSData * _Nonnull data) 87 inline id _Nullable insecurelyUnarchiveObjectFromData(NSData * _Nonnull data) 100 88 { 101 89 #pragma clang diagnostic push … … 103 91 return [NSKeyedUnarchiver unarchiveObjectWithData:data]; 104 92 #pragma clang diagnostic pop 93 } 94 95 inline id _Nullable unarchivedObjectOfClassFromData(Class _Nonnull cls, NSData * _Nonnull data) 96 { 97 #if USE(SECURE_ARCHIVER_API) 98 #if !USE(SECURE_ARCHIVER_FOR_ATTRIBUTED_STRING) 99 // Remove this code when the fix from <rdar://problem/31376830> is deployed to all relevant build targets. 100 if (cls == [NSAttributedString class]) 101 return insecurelyUnarchiveObjectFromData(data); 102 #endif 103 NSError *error; 104 id value = [NSKeyedUnarchiver unarchivedObjectOfClass:cls fromData:data error:&error]; 105 if (!value) 106 LOG_ERROR("Unable to unarchive data: %@", error); 107 return value; 108 #else 109 UNUSED_PARAM(cls); 110 return insecurelyUnarchiveObjectFromData(data); 111 #endif 105 112 } 106 113 -
trunk/Source/WebCore/editing/cocoa/EditorCocoa.mm
r226213 r226224 1 1 /* 2 * Copyright (C) 2006-201 6Apple Inc. All rights reserved.2 * Copyright (C) 2006-2017 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 143 143 return nullptr; 144 144 145 return SharedBuffer::create( insecurelyArchivedDataWithRootObject(attributedString));145 return SharedBuffer::create(securelyArchivedDataWithRootObject(attributedString)); 146 146 } 147 147 -
trunk/Source/WebCore/platform/ios/PlatformPasteboardIOS.mm
r225276 r226224 266 266 267 267 if (content.dataInAttributedStringFormat) { 268 NSAttributedString *attributedString = insecurelyUnarchiveObjectOfClassFromData(content.dataInAttributedStringFormat->createNSData().get());268 NSAttributedString *attributedString = unarchivedObjectOfClassFromData([NSAttributedString class], content.dataInAttributedStringFormat->createNSData().get()); 269 269 if (attributedString) 270 270 [representationsToRegister addRepresentingObject:attributedString]; … … 381 381 continue; 382 382 383 NSDictionary *teamDataObject = insecurelyUnarchiveObjectOfClassFromData(provider.teamData);383 NSDictionary *teamDataObject = unarchivedObjectOfClassFromData([NSDictionary class], provider.teamData); 384 384 if (!teamDataObject) 385 385 continue; … … 446 446 for (auto& type : data.orderedTypes) 447 447 [typesAsNSArray addObject:type]; 448 [representationsToRegister setTeamData: insecurelyArchivedDataWithRootObject(@{ @(originKeyForTeamData) : data.origin, @(customTypesKeyForTeamData) : typesAsNSArray })];448 [representationsToRegister setTeamData:securelyArchivedDataWithRootObject(@{ @(originKeyForTeamData) : data.origin, @(customTypesKeyForTeamData) : typesAsNSArray })]; 449 449 [representationsToRegister addData:serializedSharedBuffer.get() forType:@(PasteboardCustomData::cocoaType())]; 450 450 }
Note: See TracChangeset
for help on using the changeset viewer.