adium/adium

Parents 7af7624d7f0b
Children 609fb8ff4d6b
Forbid loading images when converting HTML pasteboards to NSAttributedStrings. This is a possible privacy issue when using Tor and unlikely to be what the user wants (why start a lot of filetransfers when sending a snippet from a webpage?).

Fixes #15724
--- a/Frameworks/Adium Framework/Source/AIMessageEntryTextView.m Tue Aug 13 00:24:57 2013 +0200
+++ b/Frameworks/Adium Framework/Source/AIMessageEntryTextView.m Thu Oct 10 02:24:58 2013 +0200
@@ -35,6 +35,7 @@
#import <AIUtilities/AIPasteboardAdditions.h>
#import <AIUtilities/AIBezierPathAdditions.h>
#import <Adium/AIContactControllerProtocol.h>
+#import <WebKit/WebKit.h>
#import <FriBidi/NSString-FBAdditions.h>
@@ -507,6 +508,13 @@
#pragma mark Pasting
+// Forbid loading the images embedded in a string when pasting.
+// They are very unlikely to work and a privacy issue.
+- (NSURLRequest *)webView:(WebView *)sender resource:(id)identifier willSendRequest:(NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource
+{
+ return nil;
+}
+
- (BOOL)handlePasteAsRichText
{
NSPasteboard *generalPasteboard = [NSPasteboard generalPasteboard];
@@ -526,6 +534,14 @@
} else if ([FILES_AND_IMAGES_TYPES containsObject:type]) {
[self addAttachmentsFromPasteboard:generalPasteboard];
handledPaste = YES;
+ } else if ([type isEqualToString:NSHTMLPboardType]) {
+ NSData *htmlData = [generalPasteboard dataForType:NSHTMLPboardType];
+ [self insertText:[[[NSAttributedString alloc] initWithData:htmlData
+ options:@{NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType,
+ NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding),
+ NSWebResourceLoadDelegateDocumentOption: self}
+ documentAttributes:NULL error:NULL] autorelease]];
+ handledPaste = YES;
}
if (handledPaste) break;