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
|
inline string
|
||||||
cleanString (string line) {
|
cleanString (string line) {
|
||||||
static const regex findVarVal ("(\\s*[a-zA-Z_*-]+=)((\"(\\\\.|[^\\\\])*\")|[^; \t]*;?)");
|
DEF_LOG ("Attachment::cleanString", "line: " << line.substr (0, 100) << "...");
|
||||||
string result;
|
|
||||||
smatch m;
|
|
||||||
|
|
||||||
while (regex_search (line, m, findVarVal)) {
|
static const regex findPart ("(((\"(\\\\.|[^\\\\])*\")|\\s|[^;\\\"])+;?)");
|
||||||
result += m.prefix ();
|
static const regex findVarVal ("(\\s*[a-zA-Z_*-]+=)(.*;?)");
|
||||||
string id (m[1]);
|
string result;
|
||||||
toLower (id);
|
smatch m1, m2;
|
||||||
result += id;
|
|
||||||
result += m[2];
|
while (regex_search (line, m1, findPart)) {
|
||||||
line = m.suffix ();
|
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')
|
if (!line.empty () && line[line.size() - 1] == '\r')
|
||||||
line = line.substr (0, line.size () - 1);
|
line = line.substr (0, line.size () - 1);
|
||||||
result += line;
|
result += line;
|
||||||
|
LOG ("result: " << result);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +345,7 @@ Attachment::readMime (ifstream &mbox, streamoff &curPos) {
|
|||||||
} else {
|
} else {
|
||||||
LOG ("add line to var: " << line);
|
LOG ("add line to var: " << line);
|
||||||
env.find (lastVar)->second += cleanString (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;
|
continue;
|
||||||
}
|
}
|
||||||
@ -346,7 +358,7 @@ Attachment::readMime (ifstream &mbox, streamoff &curPos) {
|
|||||||
if (line.length () >= colonPos && line [colonPos] == ' ')
|
if (line.length () >= colonPos && line [colonPos] == ' ')
|
||||||
++colonPos;
|
++colonPos;
|
||||||
string val (cleanString (line.length () >= colonPos ? line.substr (colonPos) : ""));
|
string val (cleanString (line.length () >= colonPos ? line.substr (colonPos) : ""));
|
||||||
LOG ("new var: <" << lastVar << " <=> " << val << ">");
|
LOG ("new var(b): <" << lastVar << " <=> " << val << ">");
|
||||||
env [lastVar] = val;
|
env [lastVar] = val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -128,7 +128,7 @@ kaz::toLower (string &content) {
|
|||||||
static locale loc;
|
static locale loc;
|
||||||
for (string::size_type i = 0; i < content.length (); ++i)
|
for (string::size_type i = 0; i < content.length (); ++i)
|
||||||
content [i] = tolower (content[i], loc);
|
content [i] = tolower (content[i], loc);
|
||||||
LOG ("content: " << content.substr (0, 100) << "...");
|
LOG ("content: " << content.substr (0, 100) << "...");
|
||||||
}
|
}
|
||||||
|
|
||||||
const string &
|
const string &
|
||||||
@ -199,8 +199,8 @@ kaz::quotedDecode (string &content) {
|
|||||||
LOG ("len: " << len);
|
LOG ("len: " << len);
|
||||||
string::iterator p (content.begin ()), q (p);
|
string::iterator p (content.begin ()), q (p);
|
||||||
for ( ;
|
for ( ;
|
||||||
p < content.end ();
|
p < content.end ();
|
||||||
++p, ++q) {
|
++p, ++q) {
|
||||||
if (*p != delim) {
|
if (*p != delim) {
|
||||||
*q = *p;
|
*q = *p;
|
||||||
continue;
|
continue;
|
||||||
|
Loading…
Reference in New Issue
Block a user