summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSlávek Banko <slavek.banko@axis.cz>2012-09-26 14:52:19 +0200
committerSlávek Banko <slavek.banko@axis.cz>2012-09-26 17:37:43 +0200
commite09b1f3dbdcdf1f21732552d0e2db11ae3d7bf58 (patch)
tree9c8de6596c04713422db2076817cf78b914e8d21
parent95248100c1b1d757a6c3ae58eda799bf46c6ead7 (diff)
downloadtdepim-e09b1f3dbdcdf1f21732552d0e2db11ae3d7bf58.tar.gz
tdepim-e09b1f3dbdcdf1f21732552d0e2db11ae3d7bf58.zip
Fix the addquotes/removequots functions in libkmime
Thanks to Francois Andriot for the patch
-rw-r--r--libkmime/kmime_util.cpp22
1 files changed, 9 insertions, 13 deletions
diff --git a/libkmime/kmime_util.cpp b/libkmime/kmime_util.cpp
index 3b19a53b1..f18a5e8d6 100644
--- a/libkmime/kmime_util.cpp
+++ b/libkmime/kmime_util.cpp
@@ -436,29 +436,25 @@ TQCString LFtoCRLF(const TQCString &s)
void removeQuots(TQCString &str)
{
- str.replace(TQRegExp("\\\""), "\"");
- str.replace(TQRegExp("\\\\"), "\\");
+ // Removes any quote or backslash caracter
+ str.replace(TQRegExp("[\\\"]"), "");
}
void removeQuots(TQString &str)
{
- str.replace(TQRegExp("\\\""), "\"");
- str.replace(TQRegExp("\\\\"), "\\");
+ // Removes any quote or backslash caracter
+ str.replace(TQRegExp("[\\\"]"), "");
}
void addQuotes(TQCString &str, bool forceQuotes)
{
- bool needsQuotes=false;
- if ( TQString( str ) .contains( TQRegExp( TQString( "\"|\\\\|=|\\]|\\[|:|;|,|\\.|,|@|<|>|\\)|\\(" ) ) ) )
- needsQuotes = true;
-
- str.replace(TQRegExp("\\"), "\\\\");
- str.replace(TQRegExp("\""), "\\\"");
-
- if (needsQuotes || forceQuotes) {
- str.insert(0,'\"');
+ if ( forceQuotes || TQString(str).contains( TQRegExp( TQString( "\"|\\\\|=|\\]|\\[|:|;|,|\\.|,|@|<|>|\\)|\\(" ) ) ) ) {
+ // Adds a backslash in front of any existing quote or backslash caracter
+ str.replace(TQRegExp("([\\\"])"), "\\\\1");
+ // Adds quote at beginning and end of thestring
+ str.insert(0,'"');
str.append("\"");
}
}