Skip to content

bug: fix parsing of FTP LIST command #507

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Dec 13, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Too late for this PR, but perhaps you could fix 'leniant' -> 'lenient' in your next PR? 🙂

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forget that, @althonos has already fixed it in #510 ! 🎉 😆

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ups, thank you @althonos!


## [2.4.14] - 2021-11-16

Expand Down
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions fs/_ftp_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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+?
Expand Down
26 changes: 26 additions & 0 deletions tests/test_ftp_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""
)

Expand Down Expand Up @@ -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",
Expand All @@ -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())
Expand Down