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;
|
||||||
|
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);
|
toLower (id);
|
||||||
result += id;
|
result += id;
|
||||||
result += m[2];
|
result += m2[2];
|
||||||
line = m.suffix ();
|
} 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user