managed rfc2047 and rfc2184 for attache name
manage name= / name*= / name*[0-9]= / name*[0-9]*=
This commit is contained in:
+27
-43
@@ -65,8 +65,8 @@ const string Attachment::ALTERNATIVE ("alternative");
|
||||
const string Attachment::KAZ_ATTACH_NAME ("vos-pieces-jointes-kaz-ici.html");
|
||||
const string Attachment::MULTIPART ("multipart/");
|
||||
|
||||
const regex Attachment::nameCharsetRegEx ( ".*name\\*=\\s*([; \t]*)");
|
||||
const regex Attachment::nameRegEx ( ".*name=\\s*((\"(\\\\.|[^\\\\])*\")|[^; \t]*).*");
|
||||
const string Attachment::nameLeftToken (".*name");
|
||||
const string Attachment::nameRightToken ("=\\s*((\"(\\\\.|[^\\\\])*\")|[^; \t]*).*");
|
||||
const regex Attachment::boundaryRegEx (".*boundary=\\s*((\"(\\\\.|[^\\\\])*\")|[^; \t]*).*");
|
||||
const regex Attachment::cidDefRegEx (".*<([^>]*)>.*");
|
||||
const regex Attachment::textRegEx (".*text/("+PLAIN+"|"+HTML+").*");
|
||||
@@ -179,47 +179,31 @@ 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);
|
||||
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);
|
||||
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;
|
||||
for (string star : {"", "\\*"}) {
|
||||
|
||||
// name= | name*=
|
||||
regex nameAloneRegEx (nameLeftToken+star+nameRightToken);
|
||||
string result = getProp (token, nameAloneRegEx);
|
||||
removeQuote (result);
|
||||
if (result.length ()) {
|
||||
LOG (("name"+star+=": ") << result);
|
||||
charsetDecode (result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// name*[0-9]= | name*[0-9]*=
|
||||
for (int id = 0; ; ++id) {
|
||||
string item = getProp (token, regex (nameLeftToken+"\\*"+to_string (id)+star+nameRightToken));
|
||||
if (item.empty ())
|
||||
break;
|
||||
result += item;
|
||||
}
|
||||
removeQuote (result);
|
||||
if (result.length ()) {
|
||||
LOG (("name*x"+star+"=: ") << result);
|
||||
charsetDecode (result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
return getUnknown (getContentType ());
|
||||
|
||||
Reference in New Issue
Block a user