Discuz! Board

 找回密码
 立即注册
搜索
热搜: 活动 交友 discuz
查看: 1901|回复: 3
打印 上一主题 下一主题

读信页标题的解码

[复制链接]

388

主题

602

帖子

2218

积分

金牌会员

Rank: 6Rank: 6

积分
2218
跳转到指定楼层
楼主
发表于 2016-3-23 16:02:24 | 显示全部楼层 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 hechengjin 于 2016-3-25 19:39 编辑

messageWindow.xul
messageWindow.js
  1. onDisplayingMessage:
  2.       function StandaloneMessageDisplayWidget_onDisplayingMessage(aMsgHdr) {
  3.     this.__proto__.__proto__.onDisplayingMessage.call(this, aMsgHdr);

  4.     // - set the window title to the message subject (and maybe the app name)
  5.     let docTitle = aMsgHdr.mime2DecodedSubject;

  6.     // If the tab hasn't got a title, or we're on Mac, don't display
  7.     // the separator.
  8.     if (docTitle && !Application.platformIsMac)
  9.         docTitle += document.documentElement
  10.                             .getAttribute("titlemenuseparator");

  11.     // If we haven't got a title at this stage add the modifier, or if
  12.     // we are on a non-mac platform, add the modifier.
  13.     if (!docTitle || !Application.platformIsMac)
  14.          docTitle += document.documentElement
  15.                              .getAttribute("titlemodifier");

  16.     document.title = docTitle;
复制代码
nsMsgI18N.cpp


回复

使用道具 举报

388

主题

602

帖子

2218

积分

金牌会员

Rank: 6Rank: 6

积分
2218
沙发
 楼主| 发表于 2016-4-5 16:11:44 | 显示全部楼层
http://www.firemail.wang/forum.p ... hlight=%B9%A4%BE%DF
先用函数base64_encode() — 使用 MIME base64 对数据进行编码
  标题字符串前加编码类型例如: =?UTF-8?B?
  标题字符串后加:?=

  例如:

  $subject = "=?UTF-8?B?".base64_encode($subject)."?=";

  将上面一句添加到代码之中,这样,发送的中文邮件标题就不是乱码了。
回复 支持 反对

使用道具 举报

388

主题

602

帖子

2218

积分

金牌会员

Rank: 6Rank: 6

积分
2218
板凳
 楼主| 发表于 2016-4-8 10:23:33 | 显示全部楼层
本帖最后由 hechengjin 于 2016-4-8 13:59 编辑

(https://www.rfc-editor.org/rfc/pdfrfc/rfc1342.txt.pdf)
  1. for (let key in rowHeaderData) {
  2.       let headers = []
  3.       for (let header of rowHeaderData[key]) {
  4.         let headerItem = {
  5.           headerName: header.headerName
  6.         }
  7.         // RFC 1342 - Representation of Non-ASCII Text in Internet Message Headers
  8.         // (https://www.rfc-editor.org/rfc/pdfrfc/rfc1342.txt.pdf)
  9.         // subject may be an encoded word with format: "=?charset?encoding?encodedText?="
  10.         // if subject is not a encoded word, do not decode it.
  11.         if (header.headerName.toLowerCase() === 'subject' &&
  12.             header.headerValue.match(EncodingTextRegx) === null) {
  13.           headerItem.headerValue = header.headerValue
  14.         } else {
  15.           headerItem.headerValue = this.decodeMimeHeaderValue(header.headerValue)
  16.         }
  17.         headers.push(headerItem)
  18.       }
  19.       currentHeaderData[key] = headers
  20.     }
复制代码
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|firemail ( 粤ICP备15085507号-1 )

GMT+8, 2024-5-19 11:48 , Processed in 0.085881 second(s), 19 queries .

Powered by Discuz! X3

© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表