Revision: 12850
http://sourceforge.net/p/skim-app/code/12850
Author: hofman
Date: 2022-04-20 21:40:06 +0000 (Wed, 20 Apr 2022)
Log Message:
-----------
Check plist type marker in skim notes data before either unarchive or
deserialize, it should be an array for plist and a dictionary for archived data.
Modified Paths:
--------------
trunk/SkimNotes/SKNUtilities.m
Modified: trunk/SkimNotes/SKNUtilities.m
===================================================================
--- trunk/SkimNotes/SKNUtilities.m 2022-04-20 09:14:58 UTC (rev 12849)
+++ trunk/SkimNotes/SKNUtilities.m 2022-04-20 21:40:06 UTC (rev 12850)
@@ -199,10 +199,14 @@
NSArray *SKNSkimNotesFromData(NSData *data) {
NSArray *noteDicts = nil;
- if ([data length]) {
- @try { noteDicts = [NSKeyedUnarchiver unarchiveObjectWithData:data]; }
- @catch (id e) {}
- if (noteDicts == nil) {
+ if ([data length] > 8) {
+ unsigned char ch = 0;
+ [data getBytes:&ch range:NSMakeRange(8, 1)];
+ ch = ch >> 4;
+ if (ch == 0xD) {
+ @try { noteDicts = [NSKeyedUnarchiver
unarchiveObjectWithData:data]; }
+ @catch (id e) {}
+ } else if (ch == 0xA) {
noteDicts = [NSPropertyListSerialization propertyListFromData:data
mutabilityOption:NSPropertyListMutableContainers format:NULL
errorDescription:NULL];
if ([noteDicts isKindOfClass:[NSArray class]]) {
for (NSMutableDictionary *dict in noteDicts) {
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
Skim-app-commit mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/skim-app-commit