From 7c5ed0be6a5f62ea2c007e560980817dfab55dc7 Mon Sep 17 00:00:00 2001 From: Yocraft-2000 <304616174+Yocraft-2000@users.noreply.github.com> Date: Sat, 18 Jul 2026 09:07:21 +0200 Subject: [PATCH] fix: http(s) match, shell escape, cleaner code --- web-launcher/launcher.luau | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/web-launcher/launcher.luau b/web-launcher/launcher.luau index 7da4214..0b19c29 100644 --- a/web-launcher/launcher.luau +++ b/web-launcher/launcher.luau @@ -8,10 +8,10 @@ local function loadLinks() for _, line in ipairs(raw) do local name, url = line:match("^([^|]+)|(.+)$") - if name and url then + if name and url and url:match("^https?://") then table.insert(links, { name = noctalia.string.trim(name), - url = noctalia.string.trim(url), + url = noctalia.string.trim(url), }) else noctalia.log("web-launcher: skipped malformed line (expected Name|https://url): " .. tostring(line)) @@ -83,11 +83,20 @@ function onQuery(query) end if text == "" then - table.insert(results, { id = link.url, title = link.name, subtitle = link.url, glyph = glyphValue, icon = iconValue }) + table.insert(results, { + id = link.url, + title = link.name, subtitle = link.url, + glyph = glyphValue, icon = iconValue + }) else local score = noctalia.fuzzyScore(text, link.name) if score ~= nil then - table.insert(results, { id = link.url, title = link.name, subtitle = link.url, glyph = glyphValue, icon = iconValue, score = score }) + table.insert(results, { + id = link.url, + title = link.name, subtitle = link.url, + glyph = glyphValue, icon = iconValue, + score = score + }) end end end @@ -95,8 +104,12 @@ function onQuery(query) launcher.setResults(query, results) end +local function shellEscape(raw) + return "'" .. raw:gsub("'", "'\\''") .. "'" +end + function onActivate(id) - noctalia.runAsync("xdg-open '" .. id .. "'") + noctalia.runAsync("xdg-open " .. shellEscape(id)) if noctalia.getConfig("notify") then noctalia.notify("Websites", "Opening " .. id) end