Lines 111-117
Link Here
|
111 |
displayName = ""; |
111 |
displayName = ""; |
112 |
addrSpec = ""; |
112 |
addrSpec = ""; |
113 |
comment = ""; |
113 |
comment = ""; |
114 |
|
114 |
|
|
|
115 |
// these strings are later copied to displayName resp. addrSpec resp. comment |
116 |
// we don't operate directly on those variables, since as ByteArray deriverates |
117 |
// they have a miserable performance on operator+ |
118 |
QString dName; |
119 |
QString aSpec; |
120 |
QString cmmt; |
121 |
|
115 |
if ( address.isEmpty() ) |
122 |
if ( address.isEmpty() ) |
116 |
return KPIM::AddressEmpty; |
123 |
return KPIM::AddressEmpty; |
117 |
|
124 |
|
Lines 129-154
Link Here
|
129 |
case TopLevel : { |
136 |
case TopLevel : { |
130 |
switch ( *p ) { |
137 |
switch ( *p ) { |
131 |
case '"' : inQuotedString = !inQuotedString; |
138 |
case '"' : inQuotedString = !inQuotedString; |
132 |
displayName += *p; |
139 |
dName += *p; |
133 |
break; |
140 |
break; |
134 |
case '(' : if ( !inQuotedString ) { |
141 |
case '(' : if ( !inQuotedString ) { |
135 |
context = InComment; |
142 |
context = InComment; |
136 |
commentLevel = 1; |
143 |
commentLevel = 1; |
137 |
} |
144 |
} |
138 |
else |
145 |
else |
139 |
displayName += *p; |
146 |
dName += *p; |
140 |
break; |
147 |
break; |
141 |
case '<' : if ( !inQuotedString ) { |
148 |
case '<' : if ( !inQuotedString ) { |
142 |
context = InAngleAddress; |
149 |
context = InAngleAddress; |
143 |
} |
150 |
} |
144 |
else |
151 |
else |
145 |
displayName += *p; |
152 |
dName += *p; |
146 |
break; |
153 |
break; |
147 |
case '\\' : // quoted character |
154 |
case '\\' : // quoted character |
148 |
displayName += *p; |
155 |
dName += *p; |
149 |
++p; // skip the '\' |
156 |
++p; // skip the '\' |
150 |
if ( *p ) |
157 |
if ( *p ) |
151 |
displayName += *p; |
158 |
dName += *p; |
152 |
else |
159 |
else |
153 |
return KPIM::UnexpectedEnd; |
160 |
return KPIM::UnexpectedEnd; |
154 |
break; |
161 |
break; |
Lines 159-215
Link Here
|
159 |
return KPIM::UnexpectedComma; |
166 |
return KPIM::UnexpectedComma; |
160 |
} |
167 |
} |
161 |
else |
168 |
else |
162 |
displayName += *p; |
169 |
dName += *p; |
163 |
break; |
170 |
break; |
164 |
default : displayName += *p; |
171 |
default : dName += *p; |
165 |
} |
172 |
} |
166 |
break; |
173 |
break; |
167 |
} |
174 |
} |
168 |
case InComment : { |
175 |
case InComment : { |
169 |
switch ( *p ) { |
176 |
switch ( *p ) { |
170 |
case '(' : ++commentLevel; |
177 |
case '(' : ++commentLevel; |
171 |
comment += *p; |
178 |
cmmt += *p; |
172 |
break; |
179 |
break; |
173 |
case ')' : --commentLevel; |
180 |
case ')' : --commentLevel; |
174 |
if ( commentLevel == 0 ) { |
181 |
if ( commentLevel == 0 ) { |
175 |
context = TopLevel; |
182 |
context = TopLevel; |
176 |
comment += ' '; // separate the text of several comments |
183 |
cmmt += ' '; // separate the text of several comments |
177 |
} |
184 |
} |
178 |
else |
185 |
else |
179 |
comment += *p; |
186 |
cmmt += *p; |
180 |
break; |
187 |
break; |
181 |
case '\\' : // quoted character |
188 |
case '\\' : // quoted character |
182 |
comment += *p; |
189 |
cmmt += *p; |
183 |
++p; // skip the '\' |
190 |
++p; // skip the '\' |
184 |
if ( *p ) |
191 |
if ( *p ) |
185 |
comment += *p; |
192 |
cmmt += *p; |
186 |
else |
193 |
else |
187 |
return KPIM::UnexpectedEnd; |
194 |
return KPIM::UnexpectedEnd; |
188 |
break; |
195 |
break; |
189 |
default : comment += *p; |
196 |
default : cmmt += *p; |
190 |
} |
197 |
} |
191 |
break; |
198 |
break; |
192 |
} |
199 |
} |
193 |
case InAngleAddress : { |
200 |
case InAngleAddress : { |
194 |
switch ( *p ) { |
201 |
switch ( *p ) { |
195 |
case '"' : inQuotedString = !inQuotedString; |
202 |
case '"' : inQuotedString = !inQuotedString; |
196 |
addrSpec += *p; |
203 |
aSpec += *p; |
197 |
break; |
204 |
break; |
198 |
case '>' : if ( !inQuotedString ) { |
205 |
case '>' : if ( !inQuotedString ) { |
199 |
context = TopLevel; |
206 |
context = TopLevel; |
200 |
} |
207 |
} |
201 |
else |
208 |
else |
202 |
addrSpec += *p; |
209 |
aSpec += *p; |
203 |
break; |
210 |
break; |
204 |
case '\\' : // quoted character |
211 |
case '\\' : // quoted character |
205 |
addrSpec += *p; |
212 |
aSpec += *p; |
206 |
++p; // skip the '\' |
213 |
++p; // skip the '\' |
207 |
if ( *p ) |
214 |
if ( *p ) |
208 |
addrSpec += *p; |
215 |
aSpec += *p; |
209 |
else |
216 |
else |
210 |
return KPIM::UnexpectedEnd; |
217 |
return KPIM::UnexpectedEnd; |
211 |
break; |
218 |
break; |
212 |
default : addrSpec += *p; |
219 |
default : aSpec += *p; |
213 |
} |
220 |
} |
214 |
break; |
221 |
break; |
215 |
} |
222 |
} |
Lines 223-231
Link Here
|
223 |
if ( context == InAngleAddress ) |
230 |
if ( context == InAngleAddress ) |
224 |
return KPIM::UnclosedAngleAddr; |
231 |
return KPIM::UnclosedAngleAddr; |
225 |
|
232 |
|
226 |
displayName = displayName.stripWhiteSpace(); |
233 |
|
227 |
comment = comment.stripWhiteSpace(); |
234 |
displayName = dName.stripWhiteSpace().latin1(); |
228 |
addrSpec = addrSpec.stripWhiteSpace(); |
235 |
comment = cmmt.stripWhiteSpace().latin1(); |
|
|
236 |
addrSpec = aSpec.stripWhiteSpace().latin1(); |
229 |
|
237 |
|
230 |
if ( addrSpec.isEmpty() ) { |
238 |
if ( addrSpec.isEmpty() ) { |
231 |
if ( displayName.isEmpty() ) |
239 |
if ( displayName.isEmpty() ) |