adium 5704:d29ff57daff3: Forbid loading images when converting H...

commits at adium.im commits at adium.im
Thu Oct 10 10:22:34 UTC 2013


details:	http://hg.adium.im/adium/rev/d29ff57daff3
revision:	5704:d29ff57daff3
branch:		adium-1.5.8
author:		Thijs Alkemade <me at thijsalkema.de>
date:		Thu Oct 10 02:24:58 2013 +0200

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

diffs (40 lines):

diff -r 7af7624d7f0b -r d29ff57daff3 Frameworks/Adium Framework/Source/AIMessageEntryTextView.m
--- 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;




More information about the commits mailing list