首页 > 其他分享 >邮件客户端对于附件的文件名的处理

邮件客户端对于附件的文件名的处理

时间:2022-10-16 21:13:16浏览次数:74  
标签:utf 文件名 -- base64 29 Content 附件 客户端

上周碰见捕获捕网易邮箱大师邮件客户端外发的附件,文件名偶尔会有乱码的问题。但是同样的文件使用foxmail外发文件,终端捕获的附件文件名就不是乱码。这里记录一下。

网易邮箱大师

先看一下网易邮箱大师的报文(已隐去部分信息)。

Date: Thu, 13 Oct 2022 10:32:16 +0800
From: 761508152 <[email protected]>
To: =?utf-8?Q?xxxx=40outlook.com?= <[email protected]>
Message-ID: <[email protected]>
Subject: qwe123
X-Mailer: MailMasterPC/4.17.5.1008 (Win7)
X-CUSTOM-MAIL-MASTER-SENT-ID: 76E8AD06-0227-45CB-A733-9FE3A74754B3
MIME-Version: 1.0
Content-Type: multipart/mixed; boundary="=_mailmaster-634778b1_0_29_="

--=_mailmaster-634778b1_0_29_=
Content-Type: text/html; charset="utf-8"
Content-Transfer-Encoding: base64

PGh0bWw+DQo8aGVhZD4NCiAgICA8bWV0YSBodHRwLWVxdWl2PSdDb250ZW50LVR5cGUnIGNvbnRl
bnQ9J3RleHQvaHRtbDsgY2hhcnNldD1VVEYtOCc+DQo8L2hlYWQ+DQo8Ym9keT4NCjxzdHlsZT4N
CiAgICBmb250ew0KICAgICAgICBsaW5lLWhlaWdodDogMS42Ow0KICAgIH0NCiAgICB1bCxvbHsN
CiAgICAgICAgcGFkZGluZy1sZWZ0OiAyMHB4Ow0KICAgICAgICBsaXN0LXN0eWxlLXBvc2l0aW9u
OiBpbnNpZGU7DQogICAgfQ0KPC9zdHlsZT4NCjxkaXYgc3R5bGUgPSAnZm9udC1mYW1pbHk65b6u
6L2v6ZuF6buRLFZlcmRhbmEsJnF1b3Q7TWljcm9zb2Z0IFlhaGVpJnF1b3Q7LFNpbVN1bixzYW5z
LXNlcmlmO2ZvbnQtc2l6ZToxNHB4OyBsaW5lLWhlaWdodDoxLjY7Jz4NCiAgICA8ZGl2ID48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WlsLW9ubGluZS5ub3Nkbi4xMjcubmV0L3FpeWVsb2dvL2RlZmF1bHRBdmF0YXIucG5nIj48L3Rk
Pjx0ZCBzdHlsZT0icGFkZGluZzogMCAwIDAgMTBweDsgY29sb3I6ICMzMTM1M2I7Ij48ZGl2IHN0
eWxlPSJmb250LXNpemU6IDE2cHg7Zm9udC13ZWlnaHQ6Ym9sZDsgd2lkdGg6MTAwJTsgd2hpdGUt
c3BhY2U6IG5vd3JhcDsgb3ZlcmZsb3c6aGlkZGVuO3RleHQtb3ZlcmZsb3c6IGVsbGlwc2lzOyI+
NzYxNTA4MTUyPC9kaXY+PC90ZD48L3RyPjx0ciB3aWR0aD0iMTAwJSIgc3R5bGU9ImZvbnQtc2l6
ZTogMTRweCAhaW1wb3J0YW50OyB3aWR0aDogMTAwJTsiPjx0ZCBjb2xzcGFuPSIyIiBzdHlsZT0i
cGFkZGluZzoxMHB4IDAgMCAwOyBmb250LXNpemU6MTRweCAhaW1wb3J0YW50OyB3aWR0aDogMTAw
JTsiPjxkaXYgc3R5bGU9IndpZHRoOiAxMDAlO2ZvbnQtc2l6ZTogMTRweCAhaW1wb3J0YW50O3dv
cmQtd3JhcDpicmVhay13b3JkO3dvcmQtYnJlYWs6YnJlYWstYWxsOyI+NzYxNTA4MTUyQHFxLmNv
bTwvZGl2PjwvdGQ+PC90cj48L3Rib2R5PjwvdGFibGU+PC9hPgogICAgICAgIDwvZGl2PgogICAg
PC9kaXY+CiA8L2Rpdj4KPC9kaXY+PCEtLfCfmIAtLT4NCjwvZGl2Pg0KPC9ib2R5Pg0KPC9odG1s
Pg==

--=_mailmaster-634778b1_0_29_=
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document; 
 name="=?utf-8?B?MTExMTExMTExMTExMTEx5rWL6K+V5paH5Lu2c3Nzc3Nzc2hlbGxvc3Nzc3Nz?=
 =?utf-8?B?c3Nzc3NzLmRvY3g=?="
Content-Transfer-Encoding: base64
Content-Disposition: attachment; 
filename="=?utf-8?B?MTExMTExMTExMTExMTEx5rWL6K+V5paH5Lu2c3Nzc3Nzc2hlbGxvc3Nzc3Nz?=
 =?utf-8?B?c3Nzc3NzLmRvY3g=?="

UEsDBBQAAgAIAAAAAABObTaBagEAAMcCAAAQAAAAZG9jUHJvcHNcYXBwLnhtbJ1Sy07DMBC8I/EP
Ue6tkyKhqtoaoSLEgZfUtD1b9iaxcGzLNoj+PRvShiBu+LQz6x3NrA03n53JPjBE7ew6L+dFnqGV
TmnbrPNddT9b5llMwiphnMV1fsSY3/DLC3gNzmNIGmNGEjau8zYlv2IsyhY7EefUttSpXehEIhga
5upaS7xz8r1Dm9iiKK4Zfia0CtXMj4L5oLj6SP8VVU72/uK+OnrS41Bh541IyJ/7STNXLnXARhYq
l4SpdIe8JHoE8CoajD03FHBwQUV+BWwoYNOKIGSi/fFyCWwC4dZ7o6VItFj+pGVw0dUpe/l2m/Xj
......

--=_mailmaster-634778b1_0_29_=
Content-Type: application/vnd.openxmlformats-officedocument.wordprocessingml.document; 
 name="111111111111111AABBCCDDssssssshellossssssssssss.docx"
Content-Transfer-Encoding: base64
Content-Disposition: attachment; 
filename="111111111111111AABBCCDDssssssshellossssssssssss.docx"

UEsDBBQAAgAIAAAAAABObTaBagEAAMcCAAAQAAAAZG9jUHJvcHNcYXBwLnhtbJ1Sy07DMBC8I/EP
Ue6tkyKhqtoaoSLEgZfUtD1b9iaxcGzLNoj+PRvShiBu+LQz6x3NrA03n53JPjBE7ew6L+dFnqGV
TmnbrPNddT9b5llMwiphnMV1fsSY3/DLC3gNzmNIGmNGEjau8zYlv2IsyhY7EefUttSpXehEIhga
......

--=_mailmaster-634778b1_0_29_=--

文件名信息是这两条,

中文文件名:filename="=?utf-8?B?MTExMTExMTExMTExMTEx5rWL6K+V5paH5Lu2c3Nzc3Nzc2hlbGxvc3Nzc3Nz?= =?utf-8?B?c3Nzc3NzLmRvY3g=?="

非中文文件名:filename="111111111111111AABBCCDDssssssshellossssssssssss.docx"

可以看到对于非中文的文件名,报文中是直接展示的,而中文文件名,使用的的是base64的编码(Content-Transfer-Encoding: base64 此字段已经说明),对于较长的中文文件名来说,网易邮箱大师客户端在处理上选则将其分隔成了多块。而我的程序中只是将头部字符串编码格式和尾部标记给移除了导致长的文件名会出现乱码。至于文件名多长会被分割,大概数了一下算是扩展名是41个字符,长度超过41个字符便会被分割。

Foxmail

foxmail中长的中文名不会被分割:=?GB18030?B?MTExMTExMTExMTExMTExsuLK1M7EvP5zc3Nzc3NzaGVsbG9zc3Nzc3Nzc3Nzc3MxMTExMTExMTExMTExMTGy4srUzsS8/nNzc3Nzc3NoZWxsb3Nzc3Nzc3Nzc3Nzcy5kb2N4?=

标签:utf,文件名,--,base64,29,Content,附件,客户端
From: https://www.cnblogs.com/heguoxing98/p/16797151.html

相关文章

  • Xeterm桌面版全面兼容航信eterm增强版客户端,免费使用
    Xeterm桌面版全面兼容航信eterm增强版客户端,免费使用下载地址:www.xeterm.com 主要功能:1、工作组管理、多黑屏账号同时登录;2、国内、国际舱位运价显示快速中文转换航班......
  • 跨平台客户端Blazor方案尝试
    一、方案选择Electron/MAUI+Blazor(AntDesginblazor)BlazorApp:BlazorRazor页面层,抽象独立层,被BlazorAppElectron/BlazorAppMAUI项目引用BlazorAppElectron:Electron......
  • redis:jedis客户端
    导入依赖<!--jedis--><dependency><groupId>redis.clients</groupId><artifactId>jedis</artifactId><version>3.7.0</version></dependency><!--单元......
  • 启动 RMAN 客户端并与之交互
    启动和退出RMANRMAN可执行文件与数据库一起自动安装,通常与其他数据库可执行文件位于同一目录中。例如,Linux上的RMAN客户端位于$ORACLE_HOME/bin. 您有以下启动RM......
  • Java Mysql客户端 Mybatis-Plus 4步快速接入
    1,pom增加依赖<dependencies><dependency><groupId>com.baomidou</groupId><artifactId>mybatis-plus-boot-starter</artifactId><version>......
  • MQTT EMQX中如何监听客户端上下线?并在业务中使用
    MQTTEMQX中如何监听客户端上下线?最近自助洗车项目改用了全新的客户端通讯方案MQTT,发现了一些问题。之前使用Websocket方式,服务端在发送入场开门命令的时候如果trycatc......
  • 分享一个自己修改的金庸小说全集安卓客户端
     前言:空闲时想在手机上回味下金庸经典的名著,以前安装用了一段时间的APP往下拉式看书用起来很不方便,于是自己花了好长时间找了十几款APP,但是都不是很理想,最后找到了一款“金......
  • python学习:获取指定目录下所有文件名os.walk和os.listdir
    1.os.walk返回指定路径下所有文件和子文件夹中所有文件列表其中文件夹下路径如下:importosdeffile_name_walk(file_dir):forroot,dirs,filesinos.walk(f......
  • 基于tauri打造的HTTP API客户端工具-CyberAPI
    国庆长假和朋友聚会的时候,和朋友谈起最近这段时间捣鼓tauri,写了一个HTTPAPI客户端工具。『你写了这么多东西,其实有想过是为了啥不?』为了啥这是一个很大的命题,当初每个项目......
  • c++游戏客户端修改记录
    c++游戏客户端编译原代码是基于WTL8.0的,可能是vs2005版本编译。本次使用vs2013升级,之后主要遇到的错误记录在此,最后编译成功了项目中已经引入了wtl8的头文件到include......