From 35bc90933ceb50612d8351f0bbd2756a0750d17b Mon Sep 17 00:00:00 2001 From: amirzak Date: Sun, 26 Feb 2023 19:46:14 +0200 Subject: [PATCH 1/2] Always 200 for OPTS UTF8 or OPTS UTF-8 ON --- pyftpdlib/handlers.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/pyftpdlib/handlers.py b/pyftpdlib/handlers.py index 54fa8279..a2002cc2 100644 --- a/pyftpdlib/handlers.py +++ b/pyftpdlib/handlers.py @@ -2992,12 +2992,14 @@ def ftp_OPTS(self, line): if line.count(' ') > 1: raise ValueError('Invalid number of arguments') if ' ' in line: - cmd, arg = line.split(' ') - if ';' not in arg: - raise ValueError('Invalid argument') + cmd, arg = line.split(' ') else: cmd, arg = line, '' - # actually the only command able to accept options is MLST + if cmd.upper() in ("UTF8", "UTF-8"): + self.respond('200 Always in UTF8 mode.') + return + if arg and ';' not in arg: + raise ValueError('Invalid argument') if cmd.upper() != 'MLST' or 'MLST' not in self.proto_cmds: raise ValueError('Unsupported command "%s"' % cmd) except ValueError as err: From f3abf96b1673b80d58a8c609062a4b0b5ae6c493 Mon Sep 17 00:00:00 2001 From: Giampaolo Rodola Date: Mon, 2 Oct 2023 00:46:25 +0200 Subject: [PATCH 2/2] fix indentation --- pyftpdlib/handlers.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyftpdlib/handlers.py b/pyftpdlib/handlers.py index a2002cc2..51c7a4c3 100644 --- a/pyftpdlib/handlers.py +++ b/pyftpdlib/handlers.py @@ -2999,7 +2999,7 @@ def ftp_OPTS(self, line): self.respond('200 Always in UTF8 mode.') return if arg and ';' not in arg: - raise ValueError('Invalid argument') + raise ValueError('Invalid argument') if cmd.upper() != 'MLST' or 'MLST' not in self.proto_cmds: raise ValueError('Unsupported command "%s"' % cmd) except ValueError as err: