From 13d2209319d04cf461e7b86a159765df340df0ba Mon Sep 17 00:00:00 2001 From: Martreides Date: Sun, 2 Aug 2026 10:19:18 +0200 Subject: [PATCH 1/2] Add URL validation. --- plugins/koinsight.koplugin/settings.lua | 27 +++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/plugins/koinsight.koplugin/settings.lua b/plugins/koinsight.koplugin/settings.lua index 01643794..045c54fa 100644 --- a/plugins/koinsight.koplugin/settings.lua +++ b/plugins/koinsight.koplugin/settings.lua @@ -218,10 +218,29 @@ function KoInsightSettings:editServerSettings() { text = _("Apply"), callback = function() - local myfields = self.settings_dialog:getFields() - self:setServerURL(myfields[1]) - UIManager:close(self.settings_dialog) - UIManager:show(InfoMessage:new({ text = _("KoInsight settings saved."), timeout = 2 })) + local myfields = self.settings_dialog:getFields() + local server_url = myfields[1] + + if server_url == "" then + UIManager:show(InfoMessage:new({ + text = _("Please enter a server URL."), + })) + return + end + + if not server_url:match("^https?://") then + UIManager:show(InfoMessage:new({ + text = _("The server URL must start with 'http://' or 'https://'.\n\n"), + })) + return + end + + self:setServerURL(server_url) + UIManager:close(self.settings_dialog) + UIManager:show(InfoMessage:new({ + text = _("KoInsight settings saved."), + timeout = 2, + })) end, }, }, From 6f0f259324dcfa90c2d34646570ddd4f5d4916b0 Mon Sep 17 00:00:00 2001 From: Martreides Date: Sun, 2 Aug 2026 10:23:44 +0200 Subject: [PATCH 2/2] Fix indentation. --- plugins/koinsight.koplugin/settings.lua | 40 ++++++++++++------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/plugins/koinsight.koplugin/settings.lua b/plugins/koinsight.koplugin/settings.lua index 045c54fa..5c1febdf 100644 --- a/plugins/koinsight.koplugin/settings.lua +++ b/plugins/koinsight.koplugin/settings.lua @@ -218,29 +218,29 @@ function KoInsightSettings:editServerSettings() { text = _("Apply"), callback = function() - local myfields = self.settings_dialog:getFields() - local server_url = myfields[1] + local myfields = self.settings_dialog:getFields() + local server_url = myfields[1] - if server_url == "" then - UIManager:show(InfoMessage:new({ - text = _("Please enter a server URL."), - })) - return - end + if server_url == "" then + UIManager:show(InfoMessage:new({ + text = _("Please enter a server URL."), + })) + return + end - if not server_url:match("^https?://") then - UIManager:show(InfoMessage:new({ - text = _("The server URL must start with 'http://' or 'https://'.\n\n"), - })) - return - end + if not server_url:match("^https?://") then + UIManager:show(InfoMessage:new({ + text = _("The server URL must start with 'http://' or 'https://'.\n\n"), + })) + return + end - self:setServerURL(server_url) - UIManager:close(self.settings_dialog) - UIManager:show(InfoMessage:new({ - text = _("KoInsight settings saved."), - timeout = 2, - })) + self:setServerURL(server_url) + UIManager:close(self.settings_dialog) + UIManager:show(InfoMessage:new({ + text = _("KoInsight settings saved."), + timeout = 2, + })) end, }, },