[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 03:26:31 UTC 2012


Git commit 92019daad53e389c0736a29843e0c1e0242f3126 by Kurt Hindenburg.
Committed on 22/12/2012 at 04:13.
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.

Previously commit trigger a sysadmin issue.

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

M  +12   -0    src/TerminalDisplay.cpp

http://commits.kde.org/konsole/92019daad53e389c0736a29843e0c1e0242f3126

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