惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Attack and Defense Labs
Attack and Defense Labs
T
Threatpost
C
Cybersecurity and Infrastructure Security Agency CISA
H
Hackread – Cybersecurity News, Data Breaches, AI and More
I
Intezer
C
Cyber Attacks, Cyber Crime and Cyber Security
The Register - Security
The Register - Security
量子位
Security Latest
Security Latest
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
大猫的无限游戏
大猫的无限游戏
小众软件
小众软件
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
C
CXSECURITY Database RSS Feed - CXSecurity.com
MyScale Blog
MyScale Blog
J
Java Code Geeks
Apple Machine Learning Research
Apple Machine Learning Research
Google DeepMind News
Google DeepMind News
WordPress大学
WordPress大学
Spread Privacy
Spread Privacy
Jina AI
Jina AI
博客园 - 【当耐特】
P
Palo Alto Networks Blog
Last Week in AI
Last Week in AI
SecWiki News
SecWiki News
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
G
GRAHAM CLULEY
宝玉的分享
宝玉的分享
Hacker News - Newest:
Hacker News - Newest: "LLM"
T
The Blog of Author Tim Ferriss
V
Vulnerabilities – Threatpost
有赞技术团队
有赞技术团队
T
Tor Project blog
H
Hacker News: Front Page
A
Arctic Wolf
NISL@THU
NISL@THU
A
About on SuperTechFans
云风的 BLOG
云风的 BLOG
Engineering at Meta
Engineering at Meta
V
V2EX
N
News and Events Feed by Topic
Webroot Blog
Webroot Blog
Know Your Adversary
Know Your Adversary
P
Privacy International News Feed
I
InfoQ
D
Docker
L
LINUX DO - 最新话题
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
U
Unit 42

博客园 - 吾非无心

MSB4019 找不到导入的项目“C:\Users\...\AppData\Local\QtMsBuild\vs-debugtools\qt_import.props” - 吾非无心 - 博客园 类/结构最后一个成员为类(string)时可能会出现“堆损坏”(HEAP CORRUPTION DETECTED)错误 GCC在C语言中内嵌汇编 asm __volatile__ QT删除python中的单行注释 double转int QJson 存储(u)longlong有问题 QT QPixmap QImage内存泄漏 QMetaObject::connectSlotsByName: No matching signal for QT数据库连接管理类 QT多重继承带来的问题及解决办法,记录备查 QT6 源码编译Win32 x86 vc++高精度计时sleep stack smashing detected 莫名其妙的错误 strdump的问题 再加一个realloc的问题 linux下简单封装读写锁 codeblocks下libacl配置 centos8 安装、配置redis6 CentOS8让uwsgi开机自动启动django(无需登录,无需手动) libevent学习一
pyftpdlib中文乱码的解决之道
吾非无心 · 2020-09-12 · via 博客园 - 吾非无心

pyftpdlib默认用常量字符串设置了编码:utf8

这本身没有问题,但问题是windows和一些FTP client 使用的不是utf8,所以中文乱码。甚至无法进入自己建立的中文目录

解决之道:修改两个源文

为了可能再使用别的编码,所以改得略复杂点:

一、filesystem.py

       在类 AbstractedFS 中:

  增加属性:encoding

    @property
    def encoding(self):
        return self.__encoding

    @encoding.setter
    def encoding(self,value):
        self.__encoding=value

  修改__init__:

def __init__(self, root, cmd_channel,encoding):
    #...
    #...
    self.__encoding=encoding

     将本文件中所有'utf8'替换为:self.encoding

    保存修改

二、修改handler

      在类 FTPHandler 中:

     同样增加属性encoding

    @property
    def encoding(self):
        return self.__encodingg
    @encoding.setter
    def encoding(self,value):
        self.__encoding=value
        self.fs.encoding=value

    在__init__中增加:

            self.__encoding='utf8'

   在方法中 def handle_auth_success(。。。)修改一下(因为改了AbstractFS构造函数):        

          self.fs = self.abstracted_fs(home, self,self.encoding)

三、使用:

    定义好handler之后,将这赋给ftpserver前:

    handler.encoding='gbk'