From 4ee4c8c3b3ebea1da2530d7487f8876c73c7c106 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 13 Jan 2020 10:59:21 +0100 Subject: [kiosk-chromium] support url-encoded bookmarks --- .../data/opt/openslx/scripts/kiosk-launch.d/00-chromium | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium b/core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium index 226b274b..67ebfcb8 100644 --- a/core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium +++ b/core/modules/kiosk-chromium/data/opt/openslx/scripts/kiosk-launch.d/00-chromium @@ -9,12 +9,21 @@ if [ "$(whoami)" = "demo" ]; then mkdir -p "$HOME/.config/chromium/Default" fi +# Helper to decode URL-encoded strings +# e.g. urldecode http%3A%2F%2Ffoobar.com -> http://foobar.com +urldecode() { + : "${*//+/ }"; echo -e "${_//%/\\x}" +} + # Helper to json'ize bookmarks given as arguments in the form: # , -> e.g. Google,https://www.google.com json_bookmarks() { local cur=0 + local name url while [ $# -ne 0 ]; do - jq --null-input --join-output --compact-output --arg id "$(( cur++ ))" --arg name "${1%%,*}" --arg url "${1#*,}" \ + name="${1%%,*}" + url="$(urldecode ${1#*,})" + jq --null-input --join-output --compact-output --arg id "$(( cur++ ))" --arg name "$name" --arg url "$url" \ '{"id": $id, "type": "url", "name": $name, "url": $url}' shift [ $# -ne 0 ] && printf "," -- cgit v1.2.3-55-g7522