diff options
author | hlaaftana <10591326+hlaaftana@users.noreply.github.com> | 2020-01-24 02:18:16 +0300 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2020-01-24 00:18:16 +0100 |
commit | 4656580b54dd6e7cc063003d65841d9f3d9a009e (patch) | |
tree | 019fdb88b180d0e1b5319bffe04022dfada8682b /lib/pure | |
parent | caaa8f285f4a8dfc1fa1e03cec87ed58edefda00 (diff) | |
download | Nim-4656580b54dd6e7cc063003d65841d9f3d9a009e.tar.gz |
Fixes asyncftpclient multiline reading, fixes #4684 (#13242)
Previously, the 4th character of `result` was checked for `'-'` every time, instead of each new line. Also made it work for taint mode.
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/asyncftpclient.nim | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/lib/pure/asyncftpclient.nim b/lib/pure/asyncftpclient.nim index c1cfc6cc6..7bbfc2a35 100644 --- a/lib/pure/asyncftpclient.nim +++ b/lib/pure/asyncftpclient.nim @@ -131,12 +131,13 @@ type const multiLineLimit = 10000 proc expectReply(ftp: AsyncFtpClient): Future[TaintedString] {.async.} = - result = await ftp.csock.recvLine() + var line = await ftp.csock.recvLine() + result = TaintedString(line) var count = 0 - while result[3] == '-': + while line[3] == '-': ## Multi-line reply. - let line = await ftp.csock.recvLine() - result.add("\n" & line) + line = await ftp.csock.recvLine() + string(result).add("\n" & line) count.inc() if count >= multiLineLimit: raise newException(ReplyError, "Reached maximum multi-line reply count.") @@ -178,7 +179,7 @@ proc connect*(ftp: AsyncFtpClient) {.async.} = await ftp.csock.connect(ftp.address, ftp.port) var reply = await ftp.expectReply() - if reply.startsWith("120"): + if string(reply).startsWith("120"): # 120 Service ready in nnn minutes. # We wait until we receive 220. reply = await ftp.expectReply() |