socket.ftp and "553 User not allow" without extra '/' for some servers
I have an issue while trying to connect to ftp on WD My Cloud (it uses some modification of pure-ftp server)
this code returns:
local ftp = require("socket.ftp")
f, e = ftp.get("ftp://myserver/books/test.txt;type=i")
print(f)
print(e)
nil
553 User not allow
but curl or wget get the file without fail
curl "ftp://myserver/books/test.txt"
Hello World!
I starts to work when I add an extra '/' after the host
local ftp = require("socket.ftp")
f, e = ftp.get("ftp://myserver//books/test.txt;type=i")
print(f)
print(e)
returns
Hello World!
nil
I believe this can be fixed in luasocket since curl and wget work somehow
Does it work if you use the parameters in a table, instead of a single url as parameter to get? See https://lunarmodules.github.io/luasocket/ftp.html
imho a full url should not strip the leading /, since it refers to an absolute path, so this is a bug. But we should verify that if you pass a table of options, that we also don't strip the leading / if given.
Does it work if you use the parameters in a table, instead of a single url as parameter to
get? See https://lunarmodules.github.io/luasocket/ftp.html
No, it doesn't work this way either
I think this code in ftp.lua
local argument = sendt.argument or
url.unescape(string.gsub(sendt.path or "", "^[/\\]", ""))
have to be replaced to
local argument = sendt.argument or url.unescape(sendt.path or "")
I'd argue that if the path is omitted, it should default to /