#67 closed defect (fixed)
ftp_stat.parse_ms_time breaks on IIS 7.5 with 4 digit year lines
Reported by: | ftputiluser | Owned by: | schwa |
---|---|---|---|
Priority: | major | Milestone: | 2.8 |
Component: | Library | Version: | |
Keywords: | directory, listing, parser, iis, year | Cc: |
Description
IIS 7.5 FTP Server displays dates with 4 digit years when in MS-DOS directory style listing mode:
lftp anonymous@localhost:~> ls -l 10-19-2012 03:13PM <DIR> SYNCDEST 10-19-2012 03:13PM <DIR> SYNCSOURCE
Parser.parse_ms_time in ftp_stat expects a two digit year and breaks on these date lines:
Traceback (most recent call last): File "D:\ECLIPSE-WS\ftputilplay\src\ftpsync.py", line 131, in <module> main() File "D:\ECLIPSE-WS\ftputilplay\src\ftpsync.py", line 128, in main sync(config_tree, source_host, target_host) File "D:\ECLIPSE-WS\ftputilplay\src\ftpsync.py", line 105, in sync syncer.sync(source_host.directory, target_host.directory, delete_on_target, use_mtimes, retries, exclude) File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\ftp_sync.py", line 208, in sync if self._source.path.isfile(source_path): File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\ftp_path.py", line 111, in isfile path, _exception_for_missing_path=False) File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\__init__.py", line 896, in stat return self._stat._stat(path, _exception_for_missing_path) File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\ftp_stat.py", line 625, in _stat _exception_for_missing_path) File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\ftp_stat.py", line 579, in __call_with_parser_retry result = method(*args, **kwargs) File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\ftp_stat.py", line 544, in _real_stat lstat_result = self._real_lstat(path, _exception_for_missing_path) File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\ftp_stat.py", line 503, in _real_lstat for stat_result in self._stat_results_from_dir(dirname): File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\ftp_stat.py", line 437, in _stat_results_from_dir self._host.time_shift()) File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\ftp_stat.py", line 377, in parse_line st_mtime = self.parse_ms_time(date, time_, time_shift) File "D:\TEMP\ftputilvirtpy\lib\site-packages\ftputil\ftp_stat.py", line 252, in parse_ms_time hour, minute, 0, 0, 0, -1) ) OverflowError: mktime argument out of range
when it generates a date of 2012+1900=3912 in these lines:
if year >= 70: year = 1900 + year else: year = 2000 + year
I've changed the code to:
if year < 100: if year >= 70: year = 1900 + year else: year = 2000 + year
This should handle most two and four digit case except for four digit years between 0 and 100. But I'm not really concerned about that old files :). A more stable solution could check for the length of the year input string before handling two digit years.
Best regards,
Mario
Change History (3)
comment:1 Changed 8 years ago by
Keywords: | directory listing parser iis year added |
---|---|
Milestone: | → 2.7.2 |
Status: | new → assigned |
comment:2 Changed 8 years ago by
Resolution: | → fixed |
---|---|
Status: | assigned → closed |
I've checked in a fix as changeset [efd6e56cc4be].
comment:3 Changed 8 years ago by
Milestone: | 2.7.2 → 2.8 |
---|
Note: See
TracTickets for help on using
tickets.
Hi Mario, thanks for the report!
I agree with your last statement. In my opinion, it's more straightforward to check the string length of the year part. I'll do it next month, when I have more time.