|
邮件过大退信、对方拒收邮件退信、Outlook发送的回执邮件内容 显示中有源码的
126邮箱退信有源码:Content-Type: Message/delivery-status
直接简单屏蔽此类型不行,因为其下还含有子域,且含有附件,直接屏蔽解析不出附件了。
RFC822 为默认根,发现一个空行 其上对应的类型即为一个子节点
D:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\mime\src\mimei.cpp
mime_find_class (const char *content_type, MimeHeaders *hdrs,
MimeDisplayOptions *opts, bool exact_match_p)
{
else if (!PL_strcasecmp(content_type+8, "disposition-notification") )
clazz = (MimeObjectClass *)&mimeNotShowClass;
else if (!PL_strcasecmp(content_type+8, "delivery-status"))
clazz = (MimeObjectClass *)&mimeNotShowClass;
else if (!PL_strcasecmp(content_type+5, "rfc822-headers"))
clazz = (MimeObjectClass *)&mimeNotShowClass;
上面这种方法 有问题,统一使用下面的方法:d:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\mime\src\mimeobj.cpp
MimeObject_parse_begin (MimeObject *obj)
{
//如果是不想显示的源码内容,在这里根据其父类型判断过滤下
if ( obj && obj->parent && (!PL_strcasecmp(obj->content_type, MESSAGE_DELIVERY_STATUS) ||
!PL_strcasecmp(obj->content_type, MESSAGE_DISPOSITION_NOTIFICATION) ||
!PL_strcasecmp(obj->content_type, TEXT_RFC822_HEADERS)))
{
obj->output_p = false;
}
thunderbird默认回执时产生两个附件Content-Type: message/disposition-notification; name="MDNPart2.txt"
Content-Type: text/rfc822-headers; name="MDNPart3.txt"
D:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mozilla\netwerk\mime\nsMimeTypes.h
#define MESSAGE_DELIVERY_STATUS "message/delivery-status"
#define MESSAGE_DISPOSITION_NOTIFICATION "message/disposition-notification"
d:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\mime\src\mimeobj.cpp
MimeObject_parse_begin (MimeObject *obj)
{
//如果是不想显示的源码内容,在这里根据其父类型判断过滤下
if ( obj->parent && (!PL_strcasecmp(obj->parent->content_type, MESSAGE_DELIVERY_STATUS) ||
!PL_strcasecmp(obj->parent->content_type, MESSAGE_DISPOSITION_NOTIFICATION) ||
!PL_strcasecmp(obj->parent->content_type, TEXT_RFC822_HEADERS)))
{
obj->output_p = false;
}
}
nsInputStreamPump::OnInputStreamReady(nsIAsyncInputStream *stream)
nsDocumentOpenInfo::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt,
nsImapCacheStreamListener::OnDataAvailable(nsIRequest *request, nsISupports * aCtxt, nsIInputStream * aInStream, uint32_t aSourceOffset, uint32_t aCount)
nsresult nsStreamConverter::OnDataAvailable(nsIRequest *request,
D:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\mime\src\mimei.cpp
MimeObject *
mime_new (MimeObjectClass *clazz, MimeHeaders *hdrs, const char *override_content_type)
{
}
d:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\mime\src\mimemoz2.cpp
extern "C" void *
mime_bridge_create_display_stream(
nsIMimeEmitter *newEmitter,
nsStreamConverter *newPluginObj2,
nsIURI *uri,
nsMimeOutputType format_out,
uint32_t whattodo,
nsIChannel *aChannel)
{
MimeObject *obj;
mime_stream_data *msd;
nsMIMESession *stream = 0;
obj = mime_new ((MimeObjectClass *)&mimeMessageClass, (MimeHeaders *) NULL, MESSAGE_RFC822);
}
extern "C" int
mime_display_stream_write (nsMIMESession *stream,
const char* buf, ///所有网络流源码数据都在这个buf里
int32_t size){
mime_stream_data *msd = (mime_stream_data *) ((nsMIMESession *)stream)->data_object;
MimeObject *obj = (msd ? msd->obj : 0);
return obj->clazz->parse_buffer((char *) buf, size, obj);
}
d:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\mime\src\mimeobj.cpp
MimeObject_parse_buffer (const char *buffer, int32_t size, MimeObject *obj)
{
return mime_LineBuffer (buffer, size,
&obj->ibuffer, &obj->ibuffer_size, &obj->ibuffer_fp,
true,
((int (*) (char *, int32_t, void *))
/* This cast is to turn void into MimeObject */
obj->clazz->parse_line),
obj);
}
d:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\mime\src\mimebuf.cpp
extern "C" int mime_LineBuffer (const char *net_buffer, int32_t net_buffer_size, char **bufferP, int32_t *buffer_sizeP, uint32_t *buffer_fpP,
bool convert_newlines_p,
int32_t (* per_line_fn) (char *line, uint32_t line_length,
void *closure),
void *closure)
{
while (net_buffer_size > 0) //循环解析每个字符 {
for (s = net_buffer; s < net_buffer_end; s++) //过虑得到一行字符
//得到的一行字符放bufferP中
status = convert_and_send_buffer(*bufferP, *buffer_fpP,
convert_newlines_p,
per_line_fn, closure);
}
}
convert_and_send_buffer(char* buf, int length, bool convert_newlines_p,
int32_t (* per_line_fn) (char *line,
uint32_t line_length,
void *closure),
void *closure)
{
return (*per_line_fn)(buf, length, closure);
}
d:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\mime\src\mimemsg.cpp
MimeMessage_parse_line (const char *aLine, int32_t aLength, MimeObject *obj) //解析消息中的每行数据
{//////////////先完成头部分获取///////////////////
MimeMessage *msg = (MimeMessage *) obj;
msg->hdrs = MimeHeaders_new(); //创建消息头
status = MimeHeaders_parse_line(line, length, msg->hdrs);//解析消息头
status = MimeMessage_close_headers(obj);//完成消息头解析
//////有子项的再调用///即已经解析出新的节点(Multipart/report;)了,后面的内容就是在此基础上进行解析
if (msg->container.nchildren)
{
if (nl)
return kid->clazz->parse_buffer (line, length, kid);//重新递归解析这个子节点
}
}
static int MimeMessage_close_headers (MimeObject *obj)//获取完整头部后的操作
{
MimeMessage *msg = (MimeMessage *) obj;
int status = 0;
char *ct = 0; /* Content-Type header */
status = MimeMessage_write_headers_html(obj); //写入头信息
body = mime_create(ct, msg->hdrs, obj->options);
status = ((MimeContainerClass *) obj->clazz)->add_child (obj, body); //在原来默认的父节点(Multipart/rfc822)上加入新的节点(Multipart/report;)
status = body->clazz->parse_begin(body);
mimeEmitterStartBody(obj->options, (obj->options->headers == MimeHeadersNone), msgID, outCharset);
}
D:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\mime\src\mimei.cppmime_create (const char *content_type, MimeHeaders *hdrs,
MimeDisplayOptions *opts, bool forceInline /* = false */)
{
clazz = mime_find_class(content_type, hdrs, opts, false); //获取子类型 这里是Multipart/report; 由于report不支持默认为 mimeMultipartMixedClass
}
MimeObjectClass *
mime_find_class (const char *content_type, MimeHeaders *hdrs,
MimeDisplayOptions *opts, bool exact_match_p)
{
bool basic_formatting = (html_as == 4) ||
(opts && opts->format_out == nsMimeOutput::nsMimeMessageAttach);
if (!PL_strcasecmp(content_type+10, "alternative"))
clazz = basic_formatting ? (MimeObjectClass *)&mimeMultipartMixedClass :
(MimeObjectClass *)&mimeMultipartAlternativeClass;
else if (!PL_strcasecmp(content_type+10, "related"))
}
d:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\mime\src\mimemult.cpp
static int
MimeMultipart_parse_line (const char *line, int32_t length, MimeObject *obj)
{
mult->state = MimeMultipartHeaders; //新段开始mult->hdrs = MimeHeaders_new();
status = ((MimeMultipartClass *) obj->clazz)->create_child(obj); //段中出现空行时,创建新节点 ---MimeMultipart_create_child
status = ((MimeMultipartClass *) obj->clazz)->create_child(obj);
}
d:\svn\Client\ThinkMail_ClientWin_2013\trunk\src\thinkmail\mailnews\mime\src\mimemult.cpp
MimeMultipart_create_child(MimeObject *obj)
{
char *ct = (mult->hdrs
? MimeHeaders_get (mult->hdrs, HEADER_CONTENT_TYPE,
true, false)
: 0);
}
|
|