fix rfc2047 / filter log / filterTest options
This commit is contained in:
@ -65,17 +65,9 @@ const string Attachment::ALTERNATIVE ("alternative");
|
||||
const string Attachment::KAZ_ATTACH_NAME (".---KazAttachment---.html");
|
||||
const string Attachment::MULTIPART ("multipart/");
|
||||
|
||||
|
||||
const regex Attachment::nameCharsetRegEx (".*name\\*=[ \t]*(.*)");
|
||||
const regex Attachment::nameRegEx (".*name=[ \t]*((\"(\\\\.|[^\\\\\r])*\")|[^\r; ]*);?.*");
|
||||
// boundary="----=_Part_796779_1154936629.1668080348646"
|
||||
// boundary="------------040709000505010508040808"
|
||||
// boundary="----------=_1668606031-941125-91"
|
||||
// boundary="_004_PAVPR10MB6792713B313048E3A259B215B2079PAVPR10MB6792EURP_";
|
||||
// boundary="_000_PAVPR10MB6792713B313048E3A259B215B2079PAVPR10MB6792EURP_"
|
||||
// boundary=--boundary_1351_64006126-2b0e-4a3b-98ac-4797d1634188
|
||||
// boundary=--boundary_1352_7e294c9a-cfab-44a0-bfb3-7310380ac7cb;
|
||||
const regex Attachment::boundaryRegEx (".*boundary=[ \t]*((\"(\\\\.|[^\\\\])*\")|[^; ]*);?.*");
|
||||
const regex Attachment::nameCharsetRegEx (".*name\\*=\\s*([; \t]*)");
|
||||
const regex Attachment::nameRegEx ( ".*name=\\s*((\"(\\\\.|[^\\\\])*\")|[^; \t]*).*");
|
||||
const regex Attachment::boundaryRegEx (".*boundary=\\s*((\"(\\\\.|[^\\\\])*\")|[^; \t]*).*");
|
||||
const regex Attachment::cidDefRegEx (".*<([^>]*)>.*");
|
||||
const regex Attachment::textRegEx (".*text/("+PLAIN+"|"+HTML+").*");
|
||||
const regex Attachment::multiRegEx ("\\s*"+MULTIPART+"(mixed|"+RELATED+"|"+ALTERNATIVE+"|"+SIGNED+").*");
|
||||
@ -188,23 +180,49 @@ Attachment::getAttachName () const {
|
||||
static string tokens [] = {contentTypeToken, contentDispositionToken};
|
||||
DEF_LOG ("Attachment::getAttachName", "");
|
||||
for (string token : tokens) {
|
||||
// name=
|
||||
string result = getProp (token, nameRegEx);
|
||||
removeQuote (result);
|
||||
if (result.length ()) {
|
||||
LOG ("name=: " << result);
|
||||
encodedWord (result);
|
||||
encodedWordDecode (result);
|
||||
return result;
|
||||
}
|
||||
// name*x=
|
||||
for (int id = 0; ; ++id) {
|
||||
string item = getProp (token, regex (".*name\\*"+to_string (id)+"=\\s*((\"(\\\\.|[^\\\\])*\")|[; \t]*).*"));
|
||||
if (item.empty ())
|
||||
break;
|
||||
result += item;
|
||||
}
|
||||
removeQuote (result);
|
||||
if (result.length ()) {
|
||||
LOG ("name*x=: " << result);
|
||||
encodedWordDecode (result);
|
||||
return result;
|
||||
}
|
||||
// name*=
|
||||
result = getProp (token, nameCharsetRegEx);
|
||||
removeQuote (result);
|
||||
if (result.length ()) {
|
||||
LOG ("name*=: " << result);
|
||||
charsetValue (result);
|
||||
charsetValueDecode (result);
|
||||
return result;
|
||||
}
|
||||
// name*x*=
|
||||
for (int id = 0; ; ++id) {
|
||||
string item = getProp (token, regex (".*name\\*"+to_string (id)+"\\*=\\s*([^; ]*)"));
|
||||
if (item.empty ())
|
||||
break;
|
||||
result += item;
|
||||
}
|
||||
removeQuote (result);
|
||||
if (result.length ()) {
|
||||
LOG ("name*x*=: " << result);
|
||||
encodedWordDecode (result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
// XXX il faut composer s'il y a plusieurs ligne filename*x=
|
||||
// XXX il faut composer s'il y a plusieurs ligne filename*x*=
|
||||
return getUnknown (getContentType ());
|
||||
}
|
||||
|
||||
@ -257,7 +275,7 @@ Attachment::isDefProp (const string &token, const string &val) const {
|
||||
if (it == env.end ())
|
||||
return false;
|
||||
// XXX case insensitive ??
|
||||
return it->second.find (val) != string::npos;
|
||||
return caseInsensitiveFind (it->second, val) != string::npos;
|
||||
}
|
||||
|
||||
// ================================================================================
|
||||
@ -312,7 +330,8 @@ Attachment::readMime (ifstream &mbox, streamoff &curPos) {
|
||||
lastVar = line.substr (0, colonPos);
|
||||
toLower (lastVar);
|
||||
LOG ("find var: " << lastVar);
|
||||
string val (cleanString (line.length () >= colonPos+2 ? line.substr (colonPos+2) : "")); // XXX check RFC " " after ": "
|
||||
// XXX check in RFC if " " after ": " (=> +2 or +1)
|
||||
string val (cleanString (line.length () >= colonPos+2 ? line.substr (colonPos+2) : ""));
|
||||
LOG ("new var: <" << lastVar << " <=> " << val << ">");
|
||||
env [lastVar] = val;
|
||||
}
|
||||
|
Reference in New Issue
Block a user