fix: url-escape paths for scp (#134)
This commit is contained in:
parent
789b486fb5
commit
a5ff72a8da
2 changed files with 36 additions and 1 deletions
|
|
@ -75,7 +75,8 @@ local function url_to_scp(url)
|
||||||
table.insert(pieces, string.format(":%d", url.port))
|
table.insert(pieces, string.format(":%d", url.port))
|
||||||
end
|
end
|
||||||
table.insert(pieces, "/")
|
table.insert(pieces, "/")
|
||||||
table.insert(pieces, url.path)
|
local escaped_path = util.url_escape(url.path)
|
||||||
|
table.insert(pieces, escaped_path)
|
||||||
return table.concat(pieces, "")
|
return table.concat(pieces, "")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -23,6 +23,40 @@ M.escape_filename = function(filename)
|
||||||
return ret
|
return ret
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local _url_escape_chars = {
|
||||||
|
[" "] = "%20",
|
||||||
|
["$"] = "%24",
|
||||||
|
["&"] = "%26",
|
||||||
|
["`"] = "%60",
|
||||||
|
[":"] = "%3A",
|
||||||
|
["<"] = "%3C",
|
||||||
|
["="] = "%3D",
|
||||||
|
[">"] = "%3E",
|
||||||
|
["?"] = "%3F",
|
||||||
|
["["] = "%5B",
|
||||||
|
["\\"] = "%5C",
|
||||||
|
["]"] = "%5D",
|
||||||
|
["^"] = "%5E",
|
||||||
|
["{"] = "%7B",
|
||||||
|
["|"] = "%7C",
|
||||||
|
["}"] = "%7D",
|
||||||
|
["~"] = "%7E",
|
||||||
|
["“"] = "%22",
|
||||||
|
["‘"] = "%27",
|
||||||
|
["+"] = "%2B",
|
||||||
|
[","] = "%2C",
|
||||||
|
["#"] = "%23",
|
||||||
|
["%"] = "%25",
|
||||||
|
["@"] = "%40",
|
||||||
|
["/"] = "%2F",
|
||||||
|
[";"] = "%3B",
|
||||||
|
}
|
||||||
|
---@param string string
|
||||||
|
---@return string
|
||||||
|
M.url_escape = function(string)
|
||||||
|
return (string:gsub(".", _url_escape_chars))
|
||||||
|
end
|
||||||
|
|
||||||
---@param bufnr integer
|
---@param bufnr integer
|
||||||
---@return nil|oil.Adapter
|
---@return nil|oil.Adapter
|
||||||
M.get_adapter = function(bufnr)
|
M.get_adapter = function(bufnr)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue