webdav: do not allow trailing slash in start folder (#11026)

reviewable/pr11039/r1
hius07 7 months ago committed by GitHub
parent 9e82761c45
commit 39d54956ec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -84,21 +84,9 @@ function WebDav:config(item, callback)
This can point to a sub-directory of the WebDAV server. This can point to a sub-directory of the WebDAV server.
The start folder is appended to the server path.]]) The start folder is appended to the server path.]])
local hint_name = _("Server display name") local title, text_name, text_address, text_username, text_password, text_folder
local text_name = ""
local hint_address = _("WebDAV address, for example https://example.com/dav")
local text_address = ""
local hint_username = _("Username")
local text_username = ""
local hint_password = _("Password")
local text_password = ""
local hint_folder = _("Start folder")
local text_folder = ""
local title
local text_button_ok = _("Add")
if item then if item then
title = _("Edit WebDAV account") title = _("Edit WebDAV account")
text_button_ok = _("Apply")
text_name = item.text text_name = item.text
text_address = item.address text_address = item.address
text_username = item.username text_username = item.username
@ -112,29 +100,24 @@ The start folder is appended to the server path.]])
fields = { fields = {
{ {
text = text_name, text = text_name,
input_type = "string", hint = _("Server display name"),
hint = hint_name ,
}, },
{ {
text = text_address, text = text_address,
input_type = "string", hint = _("WebDAV address, for example https://example.com/dav"),
hint = hint_address ,
}, },
{ {
text = text_username, text = text_username,
input_type = "string", hint = _("Username"),
hint = hint_username,
}, },
{ {
text = text_password, text = text_password,
input_type = "string",
text_type = "password", text_type = "password",
hint = hint_password, hint = _("Password"),
}, },
{ {
text = text_folder, text = text_folder,
input_type = "string", hint = _("Start folder, for example /books"),
hint = hint_folder,
}, },
}, },
buttons = { buttons = {
@ -154,18 +137,17 @@ The start folder is appended to the server path.]])
end end
}, },
{ {
text = text_button_ok, text = _("Save"),
callback = function() callback = function()
local fields = self.settings_dialog:getFields() local fields = self.settings_dialog:getFields()
-- make sure the URL is a valid path
if fields[5] ~= "" then
if string.sub(fields[5], 1, 1) ~= '/' then
fields[5] = '/' .. fields[5]
end
end
if fields[1] ~= "" and fields[2] ~= "" then if fields[1] ~= "" and fields[2] ~= "" then
-- make sure the URL is a valid path
if fields[5] ~= "" then
if not fields[5]:match('^/') then
fields[5] = '/' .. fields[5]
end
fields[5] = fields[5]:gsub("/$", "")
end
if item then if item then
-- edit -- edit
callback(item, fields) callback(item, fields)
@ -184,11 +166,9 @@ The start folder is appended to the server path.]])
}, },
}, },
}, },
input_type = "text",
} }
UIManager:show(self.settings_dialog) UIManager:show(self.settings_dialog)
self.settings_dialog:onShowKeyboard() self.settings_dialog:onShowKeyboard()
end end
function WebDav:info(item) function WebDav:info(item)

Loading…
Cancel
Save