[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

sullivan sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:38:44 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit e225cd5475dc7e2f19b71146d581e224e2eaffe3
Author: sullivan <sullivan at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Apr 25 20:23:39 2003 +0000

    	- fixed 3240676 -- REGRESSION: Using old Safari then new one
    	erases history
    
            Reviewed by Darin.
    
            * History.subproj/WebHistoryPrivate.m:
            (-[WebHistoryPrivate _loadHistoryGuts:URL:error:]):
    	The new code to use a synchronous NSURLConnection to read the
    	property list file did not take into account the two possible
    	formats of the file (NSArray or NSDictionary), so reading
    	old-style history files was completely broken. While in here,
    	I distributed the variable declarations to first use.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4186 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 7253504..7ec1ae2 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,18 @@
+2003-04-25  John Sullivan  <sullivan at apple.com>
+
+	- fixed 3240676 -- REGRESSION: Using old Safari then new one 
+	erases history
+
+        Reviewed by Darin.
+
+        * History.subproj/WebHistoryPrivate.m:
+        (-[WebHistoryPrivate _loadHistoryGuts:URL:error:]):
+	The new code to use a synchronous NSURLConnection to read the
+	property list file did not take into account the two possible
+	formats of the file (NSArray or NSDictionary), so reading
+	old-style history files was completely broken. While in here,
+	I distributed the variable declarations to first use.
+
 2003-04-24  Maciej Stachowiak  <mjs at apple.com>
 
 	Fixed build.
diff --git a/WebKit/History.subproj/WebHistoryPrivate.m b/WebKit/History.subproj/WebHistoryPrivate.m
index 8a23194..aaf1d32 100644
--- a/WebKit/History.subproj/WebHistoryPrivate.m
+++ b/WebKit/History.subproj/WebHistoryPrivate.m
@@ -347,35 +347,33 @@ NSString *DatesArrayKey = @"WebHistoryDates";
 
 - (BOOL)_loadHistoryGuts: (int *)numberOfItemsLoaded URL:(NSURL *)URL error:(NSError **)error
 {
-    NSEnumerator *enumerator;
-    int index;
-    int limit;
-    NSCalendarDate *ageLimitDate;
-    NSDictionary *fileAsDictionary = nil;
-    BOOL ageLimitPassed;
-
     *numberOfItemsLoaded = 0;
 
     NSData *data = [NSURLConnection sendSynchronousRequest:[NSURLRequest requestWithURL:URL] returningResponse:nil error:error];
-    if (data && [data length] > 0)
-        fileAsDictionary = [NSPropertyListSerialization propertyListFromData:data mutabilityOption:NSPropertyListImmutable format:nil errorDescription:nil];
-    if (fileAsDictionary == nil) {
-        // Couldn't read a dictionary; let's see if we can read an old-style array instead
-        NSArray *fileAsArray = [NSArray arrayWithContentsOfURL:URL];
-        if (fileAsArray == nil) {
-#if !ERROR_DISABLED
-            if ([URL isFileURL] && [[NSFileManager defaultManager] fileExistsAtPath: [URL path]]) {
-                ERROR("unable to read history from file %@; perhaps contents are corrupted", [URL path]);
-            }
-#endif
-            return NO;
-        } else {
-            // Convert old-style array into new-style dictionary
-            fileAsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
-                fileAsArray, DatesArrayKey,
-                [NSNumber numberWithInt:1], FileVersionKey,
-                nil];
+    id propertyList = nil;
+    if (data && [data length] > 0) {
+        propertyList = [NSPropertyListSerialization propertyListFromData:data
+                                                        mutabilityOption:NSPropertyListImmutable
+                                                                  format:nil
+                                                        errorDescription:nil];
+    }
+
+    // propertyList might be an old-style NSArray or a more modern NSDictionary.
+    // If it's an NSArray, convert it to new format before further processing.
+    NSDictionary *fileAsDictionary = nil;
+    if ([propertyList isKindOfClass:[NSDictionary class]]) {
+        fileAsDictionary = propertyList;
+    } else if ([propertyList isKindOfClass:[NSArray class]]) {
+        // Convert old-style array into new-style dictionary
+        fileAsDictionary = [NSDictionary dictionaryWithObjectsAndKeys:
+            propertyList, DatesArrayKey,
+            [NSNumber numberWithInt:1], FileVersionKey,
+            nil];
+    } else {
+        if ([URL isFileURL] && [[NSFileManager defaultManager] fileExistsAtPath: [URL path]]) {
+            ERROR("unable to read history from file %@; perhaps contents are corrupted", [URL path]);
         }
+        return NO;
     }
 
     NSNumber *fileVersionObject = [fileAsDictionary objectForKey:FileVersionKey];
@@ -394,12 +392,12 @@ NSString *DatesArrayKey = @"WebHistoryDates";
 
     NSArray *array = [fileAsDictionary objectForKey:DatesArrayKey];
         
-    limit = [[NSUserDefaults standardUserDefaults] integerForKey: @"WebKitHistoryItemLimit"];
-    ageLimitDate = [self _ageLimitDate];
-    index = 0;
+    int limit = [[NSUserDefaults standardUserDefaults] integerForKey: @"WebKitHistoryItemLimit"];
+    NSCalendarDate *ageLimitDate = [self _ageLimitDate];
+    int index = 0;
     // reverse dates so you're loading the oldest first, to minimize the number of comparisons
-    enumerator = [array reverseObjectEnumerator];
-    ageLimitPassed = NO;
+    NSEnumerator *enumerator = [array reverseObjectEnumerator];
+    BOOL ageLimitPassed = NO;
 
     NSDictionary *itemAsDictionary;
     while ((itemAsDictionary = [enumerator nextObject]) != nil) {

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list