summaryrefslogtreecommitdiffstats
path: root/redhat/tdepim/kdepim-3.5.13-fix_kio_imap4_addquotes.patch
blob: debb6ebd567296b8a111ba0c8916feb41de7a9ce (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
--- kdepim/libkmime/kmime_util.cpp.addquotes	2012-05-28 22:58:31.257167175 +0200
+++ kdepim/libkmime/kmime_util.cpp	2012-05-29 20:02:19.679233274 +0200
@@ -436,49 +436,26 @@
 
 void removeQuots(TQCString &str)
 {
-  bool inQuote=false;
-
-  for (int i=0; i < (int)str.length(); i++) {
-    if (str[i] == '"') {
-      str.remove(i,1);
-      i--;
-      inQuote = !inQuote;
-    } else {
-      if (inQuote && (str[i] == '\\'))
-        str.remove(i,1);
-    }
-  }
+  str.replace(TQRegExp("\\\""), "\"");
+  str.replace(TQRegExp("\\\\"), "\\");
 }
 
 
 void removeQuots(TQString &str)
 {
-  bool inQuote=false;
-
-  for (int i=0; i < (int)str.length(); i++) {
-    if (str[i] == '"') {
-      str.remove(i,1);
-      i--;
-      inQuote = !inQuote;
-    } else {
-      if (inQuote && (str[i] == '\\'))
-        str.remove(i,1);
-    }
-  }
+  str.replace(TQRegExp("\\\""), "\"");
+  str.replace(TQRegExp("\\\\"), "\\");
 }
 
 
 void addQuotes(TQCString &str, bool forceQuotes)
 {
   bool needsQuotes=false;
-  for (unsigned int i=0; i < str.length(); i++) {
-    if (strchr("()<>@,.;:[]=\\\"",str[i])!=0)
-      needsQuotes = true;
-    if (str[i]=='\\' || str[i]=='\"') {
-      str.insert(i, '\\');
-      i++;
-    }
-  }
+  if ( TQString( str ) .contains( TQRegExp( TQString( "\"|\\\\|=|\\]|\\[|:|;|,|\\.|,|@|<|>|\\)|\\(" ) ) ) )
+    needsQuotes = true;
+
+  str.replace(TQRegExp("\\"), "\\\\");
+  str.replace(TQRegExp("\""), "\\\"");
 
   if (needsQuotes || forceQuotes) {
     str.insert(0,'\"');