mirror of
https://github.com/Hopiu/linkchecker.git
synced 2026-03-16 22:10:26 +00:00
Fix FTP checker
In Python 2 StringIO could accept either Unicode or 8-bit strings. Similar change made for HttpUrl:06fdd78f9("Python3: fix TypeError in HttpUrl.read_content()", 2019-09-15) Non-existent FtpUrl.max_size introduced in:7b34be590("Introduce check plugins, use Python requests for http/s connections, and some code cleanups and improvements.", 2014-03-01) Additional self.direct() not added in:f107092a8("Fix handling of user/password info in URLs.", 2012-06-10)
This commit is contained in:
parent
4433556915
commit
4b06485a05
2 changed files with 4 additions and 3 deletions
|
|
@ -18,7 +18,7 @@ Handle FTP links.
|
|||
"""
|
||||
|
||||
import ftplib
|
||||
from io import StringIO
|
||||
from io import BytesIO
|
||||
|
||||
from .. import log, LOG_CHECK, LinkCheckerError, mimeutil
|
||||
from . import internpaturl, get_index_html
|
||||
|
|
@ -179,12 +179,12 @@ class FtpUrl(internpaturl.InternPatternUrl):
|
|||
else:
|
||||
# download file in BINARY mode
|
||||
ftpcmd = f"RETR {self.filename}"
|
||||
buf = StringIO()
|
||||
buf = BytesIO()
|
||||
|
||||
def stor_data(s):
|
||||
"""Helper method storing given data"""
|
||||
# limit the download size
|
||||
if (buf.tell() + len(s)) > self.max_size:
|
||||
if (buf.tell() + len(s)) > self.aggregate.config["maxfilesizedownload"]:
|
||||
raise LinkCheckerError(_("FTP file size too large"))
|
||||
buf.write(s)
|
||||
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ class TestFtp(FtpServerTest):
|
|||
"real url %s" % url,
|
||||
"valid",
|
||||
]
|
||||
self.direct(url, resultlines)
|
||||
# ftp use/password
|
||||
user = "anonymous"
|
||||
passwd = "Ftp"
|
||||
|
|
|
|||
Loading…
Reference in a new issue