diff --git a/CHANGELOG.md b/CHANGELOG.md index 392fa744..dab094b1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). ## Unreleased +- Support more leniant usernames and group names in FTP servers [#507](https://github.com/PyFilesystem/pyfilesystem2/pull/507). Closes [#506](https://github.com/PyFilesystem/pyfilesystem2/pull/506). ## [2.4.14] - 2021-11-16 diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md index 03462fc9..7e3fcbde 100644 --- a/CONTRIBUTORS.md +++ b/CONTRIBUTORS.md @@ -2,6 +2,7 @@ Many thanks to the following developers for contributing to this project: +- [Adrian Garcia Badaracco](https://github.com/adriangb) - [Alex Povel](https://github.com/alexpovel) - [Andreas Tollkötter](https://github.com/atollk) - [Andrew Scheller](https://github.com/lurch) diff --git a/fs/_ftp_parse.py b/fs/_ftp_parse.py index defc55ee..0061f875 100644 --- a/fs/_ftp_parse.py +++ b/fs/_ftp_parse.py @@ -24,9 +24,9 @@ \s+? (\d+) \s+? - ([\w\-]+) + ([A-Za-z0-9][A-Za-z0-9\-\.\_\@]*\$?) \s+? - ([\w\-]+) + ([A-Za-z0-9][A-Za-z0-9\-\.\_\@]*\$?) \s+? (\d+) \s+? diff --git a/tests/test_ftp_parse.py b/tests/test_ftp_parse.py index d027082d..bd967aed 100644 --- a/tests/test_ftp_parse.py +++ b/tests/test_ftp_parse.py @@ -50,7 +50,9 @@ def test_decode_linux(self, mock_localtime): drwxr-xr-x 12 0 0 4096 Sep 29 13:13 pub -rw-r--r-- 1 0 0 26 Mar 04 2010 robots.txt drwxr-xr-x 8 foo bar 4096 Oct 4 09:05 test + drwxr-xr-x 8 f b 4096 Oct 4 09:05 test drwxr-xr-x 2 foo-user foo-group 0 Jan 5 11:59 240485 + drwxr-xr-x 2 foo.user$ foo@group_ 0 Jan 5 11:59 240485 """ ) @@ -147,6 +149,18 @@ def test_decode_linux(self, mock_localtime): "ls": "drwxr-xr-x 8 foo bar 4096 Oct 4 09:05 test" }, }, + { + "access": { + "group": "b", + "permissions": ["g_r", "g_x", "o_r", "o_x", "u_r", "u_w", "u_x"], + "user": "f", + }, + "basic": {"is_dir": True, "name": "test"}, + "details": {"modified": 1507107900.0, "size": 4096, "type": 1}, + "ftp": { + "ls": "drwxr-xr-x 8 f b 4096 Oct 4 09:05 test" + }, + }, { "access": { "group": "foo-group", @@ -159,6 +173,18 @@ def test_decode_linux(self, mock_localtime): "ls": "drwxr-xr-x 2 foo-user foo-group 0 Jan 5 11:59 240485" }, }, + { + "access": { + "group": "foo@group_", + "permissions": ["g_r", "g_x", "o_r", "o_x", "u_r", "u_w", "u_x"], + "user": "foo.user$", + }, + "basic": {"is_dir": True, "name": "240485"}, + "details": {"modified": 1483617540.0, "size": 0, "type": 1}, + "ftp": { + "ls": "drwxr-xr-x 2 foo.user$ foo@group_ 0 Jan 5 11:59 240485" + }, + }, ] parsed = ftp_parse.parse(directory.strip().splitlines())