Fixed: <rdar://problem/4119282> clicking a link in an RTF file opens the link with...
authorcblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 May 2005 17:55:47 +0000 (17:55 +0000)
committercblu <cblu@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 May 2005 17:55:47 +0000 (17:55 +0000)
        Reviewed by mjs.

        * WebCoreSupport.subproj/WebBridge.m:
        (-[WebBridge loadURL:referrer:reload:userGesture:target:triggeringEvent:form:formValues:]): pass the passed referrer to canLoadURL::: not [self referrer]
        (-[WebBridge postWithURL:referrer:target:data:contentType:triggeringEvent:form:formValues:]): ditto
        * WebView.subproj/WebTextView.m:
        (-[WebTextView clickedOnLink:atIndex:]): call the loadURL bridge method so that security checks are made, command/option clicks work, policy delegate is consulted etc.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@9177 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit/ChangeLog
WebKit/WebCoreSupport.subproj/WebBridge.m
WebKit/WebView.subproj/WebTextView.m

index d1861dcca77e1f3d6dc68f187f0e14d424708c64..00c057b51c8576066502d8ba0374d127a8705a26 100644 (file)
@@ -1,3 +1,15 @@
+2005-05-17  Chris Blumenberg  <cblu@apple.com>
+       
+       Fixed: <rdar://problem/4119282> clicking a link in an RTF file opens the link with NSWorkspace without the usual security checks or WebView delegate control
+
+        Reviewed by mjs.
+
+        * WebCoreSupport.subproj/WebBridge.m:
+        (-[WebBridge loadURL:referrer:reload:userGesture:target:triggeringEvent:form:formValues:]): pass the passed referrer to canLoadURL::: not [self referrer]
+        (-[WebBridge postWithURL:referrer:target:data:contentType:triggeringEvent:form:formValues:]): ditto
+        * WebView.subproj/WebTextView.m:
+        (-[WebTextView clickedOnLink:atIndex:]): call the loadURL bridge method so that security checks are made, command/option clicks work, policy delegate is consulted etc.
+
 2005-05-17  Chris Blumenberg  <cblu@apple.com>
 
        Fixed: <rdar://problem/4120255> web archives on remote servers can be viewed directly (with major security issues); should download instead
index 17a6886cf27fa1f022c4c0ba9fdc40512b68e6e9..4253e073c3fd74a83d5b3e2b18368ae098215f67 100644 (file)
@@ -627,7 +627,7 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
 - (void)loadURL:(NSURL *)URL referrer:(NSString *)referrer reload:(BOOL)reload userGesture:(BOOL)forUser target:(NSString *)target triggeringEvent:(NSEvent *)event form:(DOMElement *)form formValues:(NSDictionary *)values
 {
     BOOL hideReferrer;
-    if (![self canLoadURL:URL fromReferrer:[self referrer] hideReferrer:&hideReferrer])
+    if (![self canLoadURL:URL fromReferrer:referrer hideReferrer:&hideReferrer])
         return;
 
     if ([target length] == 0) {
@@ -657,7 +657,7 @@ NSString *WebPluginContainerKey =   @"WebPluginContainer";
 - (void)postWithURL:(NSURL *)URL referrer:(NSString *)referrer target:(NSString *)target data:(NSArray *)postData contentType:(NSString *)contentType triggeringEvent:(NSEvent *)event form:(DOMElement *)form formValues:(NSDictionary *)values
 {
     BOOL hideReferrer;
-    if (![self canLoadURL:URL fromReferrer:[self referrer] hideReferrer:&hideReferrer])
+    if (![self canLoadURL:URL fromReferrer:referrer hideReferrer:&hideReferrer])
         return;
 
     if ([target length] == 0) {
index 5d126fee8bdcf183f9d3cff43026350e660aaa62..6ccf58348c82947a0f1ede0b8d5bd8fe316a653b 100644 (file)
@@ -6,17 +6,24 @@
 #import <WebKit/WebTextView.h>
 
 #import <WebKit/WebAssertions.h>
-#import <Foundation/NSURLResponse.h>
-
+#import <WebKit/WebBridge.h>
 #import <WebKit/WebDataSourcePrivate.h>
 #import <WebKit/WebDocumentInternal.h>
+#import <WebKit/WebFramePrivate.h>
 #import <WebKit/WebFrameView.h>
 #import <WebKit/WebNSObjectExtras.h>
+#import <WebKit/WebNSURLExtras.h>
 #import <WebKit/WebNSViewExtras.h>
 #import <WebKit/WebPreferences.h>
 #import <WebKit/WebTextRendererFactory.h>
 #import <WebKit/WebViewPrivate.h>
 
+#import <Foundation/NSURLResponse.h>
+
+@interface NSTextView (AppKitSecret)
++ (NSURL *)_URLForString:(NSString *)string;
+@end
+
 @interface WebTextView (ForwardDeclarations)
 - (void)_updateTextSizeMultiplier;
 @end
     return resign;
 }
 
+- (void)clickedOnLink:(id)link atIndex:(unsigned)charIndex
+{
+    NSURL *URL = nil;
+    if ([link isKindOfClass:[NSURL class]]) {
+        URL = (NSURL *)link;
+    } else if ([link isKindOfClass:[NSString class]]) {
+        URL = [[self class] _URLForString:(NSString *)link];
+    }
+    if (URL != nil) {    
+        // Call the bridge because this is where our security checks are made.
+        WebFrame *frame = [[self _web_parentWebFrameView] webFrame];
+        [[frame _bridge] loadURL:URL 
+                        referrer:[[[[frame dataSource] request] URL] _web_originalDataAsString]
+                          reload:NO
+                     userGesture:YES       
+                          target:nil
+                 triggeringEvent:[[self window] currentEvent]
+                            form:nil 
+                      formValues:nil];
+    }
+}
+
 #pragma mark PRINTING
 
 - (void)drawPageBorderWithSize:(NSSize)borderSize