Fix the addquotes/removequots functions in libkmime

Thanks to Francois Andriot for the patch
(cherry picked from commit e09b1f3dbd)
v3.5.13-sru
Slávek Banko 12 years ago
parent 4af20ec805
commit e3cb7a61df

@ -436,29 +436,25 @@ TQCString LFtoCRLF(const TQCString &s)
void removeQuots(TQCString &str) void removeQuots(TQCString &str)
{ {
str.replace(TQRegExp("\\\""), "\""); // Removes any quote or backslash caracter
str.replace(TQRegExp("\\\\"), "\\"); str.replace(TQRegExp("[\\\"]"), "");
} }
void removeQuots(TQString &str) void removeQuots(TQString &str)
{ {
str.replace(TQRegExp("\\\""), "\""); // Removes any quote or backslash caracter
str.replace(TQRegExp("\\\\"), "\\"); str.replace(TQRegExp("[\\\"]"), "");
} }
void addQuotes(TQCString &str, bool forceQuotes) void addQuotes(TQCString &str, bool forceQuotes)
{ {
bool needsQuotes=false; if ( forceQuotes || TQString(str).contains( TQRegExp( TQString( "\"|\\\\|=|\\]|\\[|:|;|,|\\.|,|@|<|>|\\)|\\(" ) ) ) ) {
if ( TQString( str ) .contains( TQRegExp( TQString( "\"|\\\\|=|\\]|\\[|:|;|,|\\.|,|@|<|>|\\)|\\(" ) ) ) ) // Adds a backslash in front of any existing quote or backslash caracter
needsQuotes = true; str.replace(TQRegExp("([\\\"])"), "\\\\1");
// Adds quote at beginning and end of thestring
str.replace(TQRegExp("\\"), "\\\\"); str.insert(0,'"');
str.replace(TQRegExp("\""), "\\\"");
if (needsQuotes || forceQuotes) {
str.insert(0,'\"');
str.append("\""); str.append("\"");
} }
} }

Loading…
Cancel
Save