diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/ftp.lua | 4 | ||||
| -rw-r--r-- | src/tcp.c | 3 |
2 files changed, 4 insertions, 3 deletions
diff --git a/src/ftp.lua b/src/ftp.lua index 9b7c1e5..a793298 100644 --- a/src/ftp.lua +++ b/src/ftp.lua | |||
| @@ -105,7 +105,7 @@ function metat.__index:send(sendt) | |||
| 105 | if self.pasvt then self:pasvconnect() end | 105 | if self.pasvt then self:pasvconnect() end |
| 106 | -- get the transfer argument and command | 106 | -- get the transfer argument and command |
| 107 | local argument = sendt.argument or | 107 | local argument = sendt.argument or |
| 108 | url.unescape(string.gsub(sendt.path or "", "^/", "")) | 108 | url.unescape(string.gsub(sendt.path or "", "^[/\\]", "")) |
| 109 | if argument == "" then argument = nil end | 109 | if argument == "" then argument = nil end |
| 110 | local command = sendt.command or "stor" | 110 | local command = sendt.command or "stor" |
| 111 | -- send the transfer command and check the reply | 111 | -- send the transfer command and check the reply |
| @@ -138,7 +138,7 @@ function metat.__index:receive(recvt) | |||
| 138 | self.try(self.pasvt or self.server, "need port or pasv first") | 138 | self.try(self.pasvt or self.server, "need port or pasv first") |
| 139 | if self.pasvt then self:pasvconnect() end | 139 | if self.pasvt then self:pasvconnect() end |
| 140 | local argument = recvt.argument or | 140 | local argument = recvt.argument or |
| 141 | url.unescape(string.gsub(recvt.path or "", "^/", "")) | 141 | url.unescape(string.gsub(recvt.path or "", "^[/\\]", "")) |
| 142 | if argument == "" then argument = nil end | 142 | if argument == "" then argument = nil end |
| 143 | local command = recvt.command or "retr" | 143 | local command = recvt.command or "retr" |
| 144 | self.try(self.tp:command(command, argument)) | 144 | self.try(self.tp:command(command, argument)) |
| @@ -213,13 +213,14 @@ static int meth_connect(lua_State *L) | |||
| 213 | unsigned short port = (unsigned short) luaL_checknumber(L, 3); | 213 | unsigned short port = (unsigned short) luaL_checknumber(L, 3); |
| 214 | p_tm tm = tm_markstart(&tcp->tm); | 214 | p_tm tm = tm_markstart(&tcp->tm); |
| 215 | const char *err = inet_tryconnect(&tcp->sock, address, port, tm); | 215 | const char *err = inet_tryconnect(&tcp->sock, address, port, tm); |
| 216 | /* have to set the class even if it failed due to non-blocking connects */ | ||
| 217 | aux_setclass(L, "tcp{client}", 1); | ||
| 216 | if (err) { | 218 | if (err) { |
| 217 | lua_pushnil(L); | 219 | lua_pushnil(L); |
| 218 | lua_pushstring(L, err); | 220 | lua_pushstring(L, err); |
| 219 | return 2; | 221 | return 2; |
| 220 | } | 222 | } |
| 221 | /* turn master object into a client object */ | 223 | /* turn master object into a client object */ |
| 222 | aux_setclass(L, "tcp{client}", 1); | ||
| 223 | lua_pushnumber(L, 1); | 224 | lua_pushnumber(L, 1); |
| 224 | return 1; | 225 | return 1; |
| 225 | } | 226 | } |
