adium 5703:aaa375918de6: Forbid loading images when converting H...

commits at adium.im commits at adium.im
Thu Oct 10 00:27:02 UTC 2013


details:	http://hg.adium.im/adium/rev/aaa375918de6
revision:	5703:aaa375918de6
branch:		adium-1.6
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 7337a82bbce8 -r aaa375918de6 Frameworks/Adium Framework/Source/AIMessageEntryTextView.m
--- a/Frameworks/Adium Framework/Source/AIMessageEntryTextView.m	Tue Sep 10 14:19:15 2013 +0200
+++ b/Frameworks/Adium Framework/Source/AIMessageEntryTextView.m	Thu Oct 10 02:24:58 2013 +0200
@@ -38,6 +38,7 @@
 #import <AIUtilities/AIPasteboardAdditions.h>
 #import <AIUtilities/AIBezierPathAdditions.h>
 #import <Adium/AIContactControllerProtocol.h>
+#import <WebKit/WebKit.h>
 
 #import <FriBidi/NSString-FBAdditions.h>
 
@@ -531,6 +532,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];
@@ -550,6 +558,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