Skip to content

Commit a2aa9f1

Browse files
authored
Use a non-greedy pattern when capturing mtime in FTP (#395)
By making this capture pattern non-greedy it will no longer capture until the last AM or PM in a directory listing line.
1 parent 34084cf commit a2aa9f1

File tree

4 files changed

+11
-1
lines changed

4 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
1616
ensuring `conftest.py` is present, fixes [#364](https://github.com/PyFilesystem/pyfilesystem2/issues/364).
1717
- Stop patching copy with Python 3.8+ because it already uses sendfile.
1818
- Fixed crash when CPython's -OO flag is used
19+
- Fixed error when parsing timestamps from a FTP directory served from a WindowsNT FTP Server, fixes [#395](https://github.com/PyFilesystem/pyfilesystem2/issues/395).
1920

2021
## [2.4.11] - 2019-09-07
2122

CONTRIBUTORS.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,4 @@ Many thanks to the following developers for contributing to this project:
1111
- [Martin Larralde](https://github.com/althonos)
1212
- [Will McGugan](https://github.com/willmcgugan)
1313
- [Zmej Serow](https://github.com/zmej-serow)
14+
- [Morten Engelhardt Olsen](https://github.com/xoriath)

fs/_ftp_parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
RE_WINDOWSNT = re.compile(
4242
r"""
4343
^
44-
(?P<modified>.*(AM|PM))
44+
(?P<modified>.*?(AM|PM))
4545
\s*
4646
(?P<size>(<DIR>|\d*))
4747
\s*

tests/test_ftp_parse.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ def test_decode_windowsnt(self, mock_localtime):
166166
directory = """\
167167
11-02-17 02:00AM <DIR> docs
168168
11-02-17 02:12PM <DIR> images
169+
11-02-17 02:12PM <DIR> AM to PM
169170
11-02-17 03:33PM 9276 logo.gif
170171
"""
171172
expected = [
@@ -183,6 +184,13 @@ def test_decode_windowsnt(self, mock_localtime):
183184
"ls": "11-02-17 02:12PM <DIR> images"
184185
},
185186
},
187+
{
188+
"basic": {"is_dir": True, "name": "AM to PM"},
189+
"details": {"modified": 1486822320.0, "type": 1},
190+
"ftp": {
191+
"ls": "11-02-17 02:12PM <DIR> AM to PM"
192+
},
193+
},
186194
{
187195
"basic": {"is_dir": False, "name": "logo.gif"},
188196
"details": {"modified": 1486827180.0, "size": 9276, "type": 2},

0 commit comments

Comments
 (0)