fix(installer): anchor and validate tag_name parsing for latest release

Greedy sed captured the last quoted string on the matched line, not
necessarily the tag_name value, and no validation caught a malformed
result before it was used to build the download URL.
This commit is contained in:
Ivan Razin
2026-07-21 08:37:22 +03:00
parent eaf1a53d2a
commit 386379fc83
+4 -4
View File
@@ -742,12 +742,12 @@ install_panel() {
fi
else
tag_version=$(curl -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" \
| grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
if [[ -z "$tag_version" ]]; then
| grep -m1 '"tag_name":' | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/')
if [[ ! "$tag_version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
tag_version=$(curl -4 -Ls "https://api.github.com/repos/MHSanaei/3x-ui/releases/latest" \
| grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
| grep -m1 '"tag_name":' | sed -E 's/.*"tag_name": *"([^"]+)".*/\1/')
fi
if [[ -z "$tag_version" ]]; then
if [[ ! "$tag_version" =~ ^v[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
echo "Failed to fetch 3x-ui version." && exit 1
fi
fi