[Konversation-devel] [Bug 121149] message is sent when pasteing text containing a newline
Eli MacKenzie
argonel at sympatico.ca
Sun Aug 27 09:13:57 CEST 2006
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.
http://bugs.kde.org/show_bug.cgi?id=121149
------- Additional Comments From argonel sympatico ca 2006-08-27 09:13 -------
SVN commit 577598 by argonel:
-prevent pasted text with leading newlines from being sent directly to the server
-retain original text when cancelling from the paste editor
-prevent text pasted via keyboard from being sent to the server when cancelling from the paste editor
CCBUG:121149
M +1 -1 commit.h
M +21 -22 ircinput.cpp
--- trunk/extragear/network/konversation/src/commit.h #577597:577598
@ -1,4 +1,4 @
// This COMMIT number is added to version string to be used as "patch level"
#ifndef COMMIT
-#define COMMIT 3145
+#define COMMIT 3146
#endif
--- trunk/extragear/network/konversation/src/ircinput.cpp #577597:577598
@ -371,8 +371,6 @
void IRCInput::paste()
{
-
- kdDebug() << "paste()" << endl;
QClipboard *cb = KApplication::kApplication()->clipboard();
setFocus();
@ -395,12 +393,21 @
emit endCompletion();
bool signal=false;
+
// replace \r with \n to make xterm pastes happy
pasteText.replace("\r","\n");
+ // remove blank lines
+ while(pasteText.contains("\n\n"))
+ pasteText.replace("\n\n","\n");
- // remove all trailing newlines
- pasteText.replace(QRegExp("\n+$"),"");
+ QRegExp reTopSpace("^ *\n");
+ while(pasteText.contains(reTopSpace))
+ pasteText.remove(reTopSpace);
+ QRegExp reBottomSpace("\n *$");
+ while(pasteText.contains(reBottomSpace))
+ pasteText.remove(reBottomSpace);
+
// does the text contain at least one newline character?
if(pasteText.find('\n')!=-1)
{
@ -409,15 +416,15 @
unsigned int rpos=pasteText.findRev('\n');
// emit the signal if there's a line break in the middle of the text
- if(pos>0 && pos!=(pasteText.length()-1)) signal=true;
+ if(pos>0 && pos!=(pasteText.length()-1))
+ signal=true;
// emit the signal if there's more than one line break in the text
- if(pos!=rpos) signal=true;
+ if(pos!=rpos)
+ signal=true;
// Remove the \n from end of the line if there's only one \n
if(!signal)
- {
pasteText.remove('\n');
- }
}
else
{
@ -454,18 +461,7 @
{
int doPaste=KMessageBox::Yes;
- // Don't use QString::stripWhiteSpace() because it deletes spaces in the first line too.
- // remove waste spaces (including LF)
- QRegExp reTopSpace("^ *\n");
- while(text.contains(reTopSpace))
- text.remove(reTopSpace);
- QRegExp reBottomSpace("\n *$");
- while(text.contains(reBottomSpace))
- text.remove(reBottomSpace);
- // remove blank lines
- while(text.contains("\n\n"))
- text.replace("\n\n","\n");
-
+ //text is now preconditioned when you get here
int lines=text.contains('\n');
if(text.length()>256 || lines)
@ -483,8 +479,11 @
if (doPaste==KMessageBox::No)
{
- text=MultilineEdit::edit(this,text);
- return true;
+ QString ret(MultilineEdit::edit(this,text));
+ if (ret.isEmpty())
+ return false;
+ text=ret;
+ return false;
}
return (doPaste==KMessageBox::Yes);
More information about the Konversation-devel
mailing list