]> git.saurik.com Git - cydia.git/commitdiff
Disallow serializing redirected garbage to the state.
authorJay Freeman (saurik) <saurik@saurik.com>
Sat, 5 Mar 2011 12:57:29 +0000 (04:57 -0800)
committerJay Freeman (saurik) <saurik@saurik.com>
Mon, 7 Mar 2011 10:41:37 +0000 (02:41 -0800)
CyteKit/WebViewController.h
CyteKit/WebViewController.mm

index 89ebe61f4eec3971a8da9266f80e0feec74d0564..95724872f6c88efe147b14531b71993bdd68276e 100644 (file)
@@ -72,6 +72,9 @@
     bool error_;
     _H<NSURLRequest> request_;
 
     bool error_;
     _H<NSURLRequest> request_;
 
+    _H<NSURLRequest> stage1_;
+    _H<NSURLRequest> stage2_;
+
     _transient NSNumber *sensitive_;
 
     NSString *title_;
     _transient NSNumber *sensitive_;
 
     NSString *title_;
index d3b12a6032366ec18943540bc0a7535c84ec445a..8b82229a1e59f8927898883bc63bc36a78776bcb 100644 (file)
@@ -16,6 +16,7 @@ extern NSString * const kCAFilterNearest;
 
 #include <WebCore/WebCoreThread.h>
 
 
 #include <WebCore/WebCoreThread.h>
 
+#include <WebKit/WebKitErrors.h>
 #include <WebKit/WebPreferences.h>
 
 #include <WebKit/DOMCSSPrimitiveValue.h>
 #include <WebKit/WebPreferences.h>
 
 #include <WebKit/DOMCSSPrimitiveValue.h>
@@ -344,6 +345,13 @@ float CYScrollViewDecelerationRateNormal;
     if ([[error domain] isEqualToString:NSURLErrorDomain] && [error code] == NSURLErrorCancelled)
         return;
 
     if ([[error domain] isEqualToString:NSURLErrorDomain] && [error code] == NSURLErrorCancelled)
         return;
 
+    if ([[error domain] isEqualToString:WebKitErrorDomain] && [error code] == WebKitErrorFrameLoadInterruptedByPolicyChange) {
+        request_ = (id) stage2_;
+        stage1_ = nil;
+        stage2_ = nil;
+        return;
+    }
+
     if ([frame parentFrame] == nil) {
         [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
             [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],
     if ([frame parentFrame] == nil) {
         [self loadURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@?%@",
             [[NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@"error" ofType:@"html"]] absoluteString],
@@ -421,8 +429,12 @@ float CYScrollViewDecelerationRateNormal;
 }
 
 - (void) webView:(WebView *)view didDecidePolicy:(CYWebPolicyDecision)decision forNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame {
 }
 
 - (void) webView:(WebView *)view didDecidePolicy:(CYWebPolicyDecision)decision forNavigationAction:(NSDictionary *)action request:(NSURLRequest *)request frame:(WebFrame *)frame {
-    if (decision == CYWebPolicyDecisionUse && !error_)
-        request_ = request;
+    if ([frame parentFrame] == nil)
+        if (decision == CYWebPolicyDecisionUse)
+            if (!error_) {
+                stage1_ = (id) request_;
+                request_ = request;
+            }
 }
 
 - (void) webView:(WebView *)view decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
 }
 
 - (void) webView:(WebView *)view decidePolicyForNewWindowAction:(NSDictionary *)action request:(NSURLRequest *)request newFrameName:(NSString *)frame decisionListener:(id<WebPolicyDecisionListener>)listener {
@@ -470,6 +482,9 @@ float CYScrollViewDecelerationRateNormal;
     [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
 
     if ([frame parentFrame] == nil) {
     [loading_ removeObject:[NSValue valueWithNonretainedObject:frame]];
 
     if ([frame parentFrame] == nil) {
+        stage1_ = nil;
+        stage2_ = nil;
+
         if (DOMDocument *document = [frame DOMDocument])
             if (DOMNodeList<NSFastEnumeration> *bodies = [document getElementsByTagName:@"body"])
                 for (DOMHTMLBodyElement *body in (id) bodies) {
         if (DOMDocument *document = [frame DOMDocument])
             if (DOMNodeList<NSFastEnumeration> *bodies = [document getElementsByTagName:@"body"])
                 for (DOMHTMLBodyElement *body in (id) bodies) {
@@ -526,6 +541,9 @@ float CYScrollViewDecelerationRateNormal;
         style_ = nil;
         function_ = nil;
 
         style_ = nil;
         function_ = nil;
 
+        stage2_ = (id) stage1_;
+        stage1_ = nil;
+
         [self setHidesNavigationBar:NO];
 
         // XXX: do we still need to do this?
         [self setHidesNavigationBar:NO];
 
         // XXX: do we still need to do this?