Deprecate TaintedString (#15423)
Co-authored-by: Timothee Cour <timothee.cour2@gmail.com> Co-authored-by: Dominik Picheta <dominikpicheta@googlemail.com>
This commit is contained in:
parent
7b632f9ccb
commit
78a99587a4
36 changed files with 184 additions and 229 deletions
|
|
@ -134,9 +134,9 @@ type
|
|||
|
||||
const multiLineLimit = 10000
|
||||
|
||||
proc expectReply(ftp: AsyncFtpClient): Future[TaintedString] {.async.} =
|
||||
proc expectReply(ftp: AsyncFtpClient): Future[string] {.async.} =
|
||||
var line = await ftp.csock.recvLine()
|
||||
result = TaintedString(line)
|
||||
result = line
|
||||
var count = 0
|
||||
while line.len > 3 and line[3] == '-':
|
||||
## Multi-line reply.
|
||||
|
|
@ -146,7 +146,7 @@ proc expectReply(ftp: AsyncFtpClient): Future[TaintedString] {.async.} =
|
|||
if count >= multiLineLimit:
|
||||
raise newException(ReplyError, "Reached maximum multi-line reply count.")
|
||||
|
||||
proc send*(ftp: AsyncFtpClient, m: string): Future[TaintedString] {.async.} =
|
||||
proc send*(ftp: AsyncFtpClient, m: string): Future[string] {.async.} =
|
||||
## Send a message to the server, and wait for a primary reply.
|
||||
## ``\c\L`` is added for you.
|
||||
##
|
||||
|
|
@ -158,9 +158,9 @@ proc send*(ftp: AsyncFtpClient, m: string): Future[TaintedString] {.async.} =
|
|||
await ftp.csock.send(m & "\c\L")
|
||||
return await ftp.expectReply()
|
||||
|
||||
proc assertReply(received: TaintedString, expected: varargs[string]) =
|
||||
proc assertReply(received: string, expected: varargs[string]) =
|
||||
for i in items(expected):
|
||||
if received.string.startsWith(i): return
|
||||
if received.startsWith(i): return
|
||||
raise newException(ReplyError,
|
||||
"Expected reply '$1' got: $2" %
|
||||
[expected.join("' or '"), received.string])
|
||||
|
|
@ -169,7 +169,7 @@ proc pasv(ftp: AsyncFtpClient) {.async.} =
|
|||
## Negotiate a data connection.
|
||||
ftp.dsock = newAsyncSocket()
|
||||
|
||||
var pasvMsg = (await ftp.send("PASV")).string.strip.TaintedString
|
||||
var pasvMsg = (await ftp.send("PASV")).strip
|
||||
assertReply(pasvMsg, "227")
|
||||
var betweenParens = captureBetween(pasvMsg.string, '(', ')')
|
||||
var nums = betweenParens.split(',')
|
||||
|
|
@ -201,11 +201,11 @@ proc connect*(ftp: AsyncFtpClient) {.async.} =
|
|||
if ftp.pass != "":
|
||||
assertReply(await(ftp.send("PASS " & ftp.pass)), "230")
|
||||
|
||||
proc pwd*(ftp: AsyncFtpClient): Future[TaintedString] {.async.} =
|
||||
proc pwd*(ftp: AsyncFtpClient): Future[string] {.async.} =
|
||||
## Returns the current working directory.
|
||||
let wd = await ftp.send("PWD")
|
||||
assertReply wd, "257"
|
||||
return wd.string.captureBetween('"').TaintedString # "
|
||||
return wd.captureBetween('"') # "
|
||||
|
||||
proc cd*(ftp: AsyncFtpClient, dir: string) {.async.} =
|
||||
## Changes the current directory on the remote FTP server to ``dir``.
|
||||
|
|
@ -253,7 +253,7 @@ proc createDir*(ftp: AsyncFtpClient, dir: string, recursive = false){.async.} =
|
|||
if not recursive:
|
||||
assertReply(await(ftp.send("MKD " & dir.normalizePathSep)), "257")
|
||||
else:
|
||||
var reply = TaintedString""
|
||||
var reply = ""
|
||||
var previousDirs = ""
|
||||
for p in split(dir, {os.DirSep, os.AltSep}):
|
||||
if p != "":
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue