From 7ed7e7fe7352357fc8a0ad86835f94d037a9f3cd Mon Sep 17 00:00:00 2001 From: Kyle Gospodnetich Date: Sun, 28 Jan 2024 21:20:02 -0800 Subject: [PATCH] fix: Escape special characters in motd script --- system_files/desktop/shared/usr/libexec/ublue-motd | 9 ++++++++- .../desktop/shared/usr/share/ublue-os/motd/bazzite.md | 2 +- .../usr/share/ublue-os/motd/tips/10-desktop-tips.md | 6 +++--- 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/system_files/desktop/shared/usr/libexec/ublue-motd b/system_files/desktop/shared/usr/libexec/ublue-motd index a8963e10..9afe6d19 100755 --- a/system_files/desktop/shared/usr/libexec/ublue-motd +++ b/system_files/desktop/shared/usr/libexec/ublue-motd @@ -1,9 +1,16 @@ #!/usr/bin/bash +escape() { + sed 's/[&/\]/\\&/g' <<< "$1" +} + TIP_FILE=$(ls "/usr/share/ublue-os/motd/tips/"*".md" | shuf -n 1) if [[ -f "$TIP_FILE" ]]; then IMAGE_INFO="/usr/share/ublue-os/image-info.json" IMAGE_NAME=$(jq -r '."image-name"' < $IMAGE_INFO) + IMAGE_NAME_ESCAPED=$(escape "$IMAGE_NAME") IMAGE_TAG=$(jq -r '."image-tag"' < $IMAGE_INFO) + IMAGE_TAG_ESCAPED=$(escape "$IMAGE_TAG") TIP=$(shuf -n 1 "$TIP_FILE") - sed -e "s/%IMAGE_NAME%/$IMAGE_NAME/g" -e "s/%IMAGE_TAG%/$IMAGE_TAG/g" -e "s/%TIP%/$TIP/g" /usr/share/ublue-os/motd/bazzite.md | /usr/bin/glow -s auto - + TIP_ESCAPED=$(escape "$TIP") + sed -e "s/%IMAGE_NAME%/$IMAGE_NAME_ESCAPED/g" -e "s/%IMAGE_TAG%/$IMAGE_TAG_ESCAPED/g" -e "s/%TIP%/$TIP_ESCAPED/g" /usr/share/ublue-os/motd/bazzite.md | /usr/bin/glow -s auto - fi \ No newline at end of file diff --git a/system_files/desktop/shared/usr/share/ublue-os/motd/bazzite.md b/system_files/desktop/shared/usr/share/ublue-os/motd/bazzite.md index 8ee98b63..459ca434 100644 --- a/system_files/desktop/shared/usr/share/ublue-os/motd/bazzite.md +++ b/system_files/desktop/shared/usr/share/ublue-os/motd/bazzite.md @@ -7,7 +7,7 @@ | `ujust toggle-user-motd` | Toggle this banner on/off | | `neofetch` | View system information | -󰋼 *%TIP%* +󰋼 %TIP% - [ Report an issue](https://github.com/ublue-os/bazzite/issues) - [󰙯 Discord](https://discord.bazzite.gg/) - [󰈙 Documentation](http://docs.bazzite.gg/) \ No newline at end of file diff --git a/system_files/desktop/shared/usr/share/ublue-os/motd/tips/10-desktop-tips.md b/system_files/desktop/shared/usr/share/ublue-os/motd/tips/10-desktop-tips.md index 571b6b3f..5cf34577 100644 --- a/system_files/desktop/shared/usr/share/ublue-os/motd/tips/10-desktop-tips.md +++ b/system_files/desktop/shared/usr/share/ublue-os/motd/tips/10-desktop-tips.md @@ -1,5 +1,5 @@ It is **always** better to install packages with Distrobox than to layer them with rpm-ostree. `ujust distrobox` makes it easy! -Packages installed in Distrobox can be exported to appear like any other application ([View documentation](https://github.com/89luca89/distrobox/blob/main/docs/usage/distrobox-export.md)). -Update break something? You can roll back and pin the previous release or rebase by build date ([View our guide](https://universal-blue.discourse.group/docs?topic=513)). +Packages installed in Distrobox can be exported to appear like any other application - [View documentation](https://github.com/89luca89/distrobox/blob/main/docs/usage/distrobox-export.md). +Update break something? You can roll back and pin the previous release or rebase by build date - [View our guide](https://universal-blue.discourse.group/docs?topic=513). Installing a non-Steam Windows game? Lutris is pre-installed for better handling of wine prefixes. -BTRFS is used by default for external drives, and we recommend that or EXT4 over NTFS ([More info here](https://github.com/ValveSoftware/Proton/wiki/Using-a-NTFS-disk-with-Linux-and-Windows)). \ No newline at end of file +BTRFS is used by default for external drives, and we recommend that or EXT4 over NTFS - [More info here](https://github.com/ValveSoftware/Proton/wiki/Using-a-NTFS-disk-with-Linux-and-Windows). \ No newline at end of file