fix bug tolowercase in base64 headers
This commit is contained in:
parent
511e14785b
commit
331db8370d
@ -296,23 +296,35 @@ Attachment::Attachment (ifstream &mbox, const int &level, const streamoff beginI
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
/*! lower case "var in string " VAR=val; ..." */
|
||||
inline string
|
||||
cleanString (string line) {
|
||||
static const regex findVarVal ("(\\s*[a-zA-Z_*-]+=)((\"(\\\\.|[^\\\\])*\")|[^; \t]*;?)");
|
||||
string result;
|
||||
smatch m;
|
||||
DEF_LOG ("Attachment::cleanString", "line: " << line.substr (0, 100) << "...");
|
||||
|
||||
while (regex_search (line, m, findVarVal)) {
|
||||
result += m.prefix ();
|
||||
string id (m[1]);
|
||||
toLower (id);
|
||||
result += id;
|
||||
result += m[2];
|
||||
line = m.suffix ();
|
||||
static const regex findPart ("(((\"(\\\\.|[^\\\\])*\")|\\s|[^;\\\"])+;?)");
|
||||
static const regex findVarVal ("(\\s*[a-zA-Z_*-]+=)(.*;?)");
|
||||
string result;
|
||||
smatch m1, m2;
|
||||
|
||||
while (regex_search (line, m1, findPart)) {
|
||||
if (m1.prefix ().length ())
|
||||
result += m1.prefix (); // XXX when \" on multi-lines
|
||||
string part (m1[1]);
|
||||
LOG ("part: " << part);
|
||||
if (regex_search (part, m2, findVarVal) && !m2.prefix ().length ()) {
|
||||
string id (m2[1]);
|
||||
LOG ("id: " << id);
|
||||
toLower (id);
|
||||
result += id;
|
||||
result += m2[2];
|
||||
} else
|
||||
result += part;
|
||||
line = m1.suffix ();
|
||||
}
|
||||
if (!line.empty () && line[line.size() - 1] == '\r')
|
||||
line = line.substr (0, line.size () - 1);
|
||||
result += line;
|
||||
LOG ("result: " << result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -333,7 +345,7 @@ Attachment::readMime (ifstream &mbox, streamoff &curPos) {
|
||||
} else {
|
||||
LOG ("add line to var: " << line);
|
||||
env.find (lastVar)->second += cleanString (line);
|
||||
LOG ("new val: <" << lastVar << " <=> " << env.find (lastVar)->second << ">");
|
||||
LOG ("new val(a): <" << lastVar << " <=> " << env.find (lastVar)->second << ">");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
@ -346,7 +358,7 @@ Attachment::readMime (ifstream &mbox, streamoff &curPos) {
|
||||
if (line.length () >= colonPos && line [colonPos] == ' ')
|
||||
++colonPos;
|
||||
string val (cleanString (line.length () >= colonPos ? line.substr (colonPos) : ""));
|
||||
LOG ("new var: <" << lastVar << " <=> " << val << ">");
|
||||
LOG ("new var(b): <" << lastVar << " <=> " << val << ">");
|
||||
env [lastVar] = val;
|
||||
}
|
||||
}
|
||||
|
@ -128,7 +128,7 @@ kaz::toLower (string &content) {
|
||||
static locale loc;
|
||||
for (string::size_type i = 0; i < content.length (); ++i)
|
||||
content [i] = tolower (content[i], loc);
|
||||
LOG ("content: " << content.substr (0, 100) << "...");
|
||||
LOG ("content: " << content.substr (0, 100) << "...");
|
||||
}
|
||||
|
||||
const string &
|
||||
@ -199,8 +199,8 @@ kaz::quotedDecode (string &content) {
|
||||
LOG ("len: " << len);
|
||||
string::iterator p (content.begin ()), q (p);
|
||||
for ( ;
|
||||
p < content.end ();
|
||||
++p, ++q) {
|
||||
p < content.end ();
|
||||
++p, ++q) {
|
||||
if (*p != delim) {
|
||||
*q = *p;
|
||||
continue;
|
||||
|
Loading…
Reference in New Issue
Block a user