[kde-doc-english] [konsole] src: Add Dialog warning when huge amounts of text is about to be pasted

Kurt Hindenburg kurt.hindenburg at gmail.com
Sat Dec 22 02:54:47 UTC 2012


Git commit e45674ae3fd1c6ef50332e3fc7dfc66f5562c8e2 by Kurt Hindenburg.
Committed on 22/12/2012 at 03:53.
Pushed by hindenburg into branch 'master'.

Add Dialog warning when huge amounts of text is about to be pasted

Currently there is no way to stop an accidently paste into the terminal.
This patch adds a dialog when 8000+ characters are pasted asking if
the user really wants to do this.  At most the user will see this once
as there is a "Don't show again" box.

FEATURE: 162625
REVIEW: 107570
FIXED-IN: 4.11
GUI:

M  +12   -0    src/TerminalDisplay.cpp

http://commits.kde.org/konsole/e45674ae3fd1c6ef50332e3fc7dfc66f5562c8e2

diff --git a/src/TerminalDisplay.cpp b/src/TerminalDisplay.cpp
index c4ad23f..57e77a3 100644
--- a/src/TerminalDisplay.cpp
+++ b/src/TerminalDisplay.cpp
@@ -51,6 +51,7 @@
 #include <KIO/NetAccess>
 #include <konq_operations.h>
 #include <KFileItem>
+#include <KMessageBox>
 
 // Konsole
 #include "Filter.h"
@@ -2571,6 +2572,17 @@ void TerminalDisplay::doPaste(QString text, bool appendReturn)
     if (appendReturn)
         text.append("\r");
 
+    if (text.length() > 8000) {
+        if (KMessageBox::warningContinueCancel(window(),
+                        i18n("Are you sure you want to paste %1 characters?",
+                             text.length()),
+                        i18n("Confirm Paste"),
+                        KStandardGuiItem::cont(),
+                        KStandardGuiItem::cancel(),
+                        "ShowPasteHugeTextWarning") == KMessageBox::Cancel)
+            return;
+    }
+
     if (!text.isEmpty()) {
         text.replace('\n', '\r');
         // perform paste by simulating keypress events


More information about the kde-doc-english mailing list