Warn against a multi-line paste
By akinori.mu... on February 07, 2011 06:04 (imported from Google Code)
Pasting a multi-line string (a string containing a LF) is too easy to be done when it may lead to a tragedy.
I'd like a kind warning shown when such a request happens to take place.
Here is a minimal patch (I'm seeing a message that says "Issue attachment storage quota exceeded") to show what I exactly mean.
You can of course make this an option that's turned off by default.
From b3da52886c5b6017e35f9df438cfb35e790504ee Mon Sep 17 00:00:00 2001
From: Akinori MUSHA <knu@idaemons.org>
Date: Mon, 7 Feb 2011 14:52:22 +0900
Subject: [PATCH] Warn if a multi-line string is being pasted.
---
PTYSession.m | 10 ++++++++++
1 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/PTYSession.m b/PTYSession.m
index 6e255bb..6f956f7 100644
--- a/PTYSession.m
+++ b/PTYSession.m
@@ -1166,6 +1166,16 @@ static NSString* SESSION_ARRANGEMENT_WORKING_DIRECTORY = @"Working Directory";
[str replaceOccurrencesOfString:@""" withString:@"\"" options:NSLiteralSearch range:NSMakeRange(0, [str length])];
[str replaceOccurrencesOfString:@" " withString:@"\ " options:NSLiteralSearch range:NSMakeRange(0, [str length])];
}
+
- if ([str rangeOfString:@"\n"].location != NSNotFound &&
-
NSRunAlertPanel(NSLocalizedStringFromTableInBundle(@"Paste a multi-line string?", @"iTerm", [NSBundle bundleForClass: [self class]], @"Paste a multi-line string"),
-
str,
-
NSLocalizedStringFromTableInBundle(@"OK", @"iTerm", [NSBundle bundleForClass: [self class]], @"OK"),
-
NSLocalizedStringFromTableInBundle(@"Cancel", @"iTerm", [NSBundle bundleForClass: [self class]], @"Cancel"),
-
nil) != NSAlertDefaultReturn) {
-
return;
- }
- if ([sender tag] & 2) {
[slowPasteBuffer setString:str];
[self pasteSlowly:nil];
--
1.7.3.5