From 2595821aa41975b899cf59bd92c485c862bd5cea Mon Sep 17 00:00:00 2001 From: niurenpeng Date: Sun, 19 Apr 2026 13:16:10 +0800 Subject: [PATCH] fix: preserve subscription UA with spaces in download_by_curl The User-Agent string (e.g. ClashX UA containing spaces and parens) was assembled into a single UA_ARG variable and expanded unquoted at each curl invocation. Word-splitting truncated the UA to its first token and turned the rest into stray positional args that curl treated as extra URLs, causing 404s on subscription updates. Switch to positional parameters with set --, expanded as "$@", so the flag and its value travel as two intact arguments regardless of whitespace in the UA. Co-Authored-By: Claude Opus 4.7 (1M context) --- fancyss/scripts/ss_node_subscribe.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/fancyss/scripts/ss_node_subscribe.sh b/fancyss/scripts/ss_node_subscribe.sh index 80622e658..1110e26bb 100755 --- a/fancyss/scripts/ss_node_subscribe.sh +++ b/fancyss/scripts/ss_node_subscribe.sh @@ -6543,21 +6543,21 @@ download_by_curl(){ local UA=$(get_ua) if [ -n "${UA}" ];then echo_date "🪧使用UA:$UA" - local UA_ARG="--user-agent ${UA}" + set -- --user-agent "${UA}" else echo_date "🪧使用UA:curl" - local UA_ARG="" + set -- fi if [ ! -L "/tmp/curl-update" ];then ln -sf /koolshare/bin/curl-fancyss /tmp/curl-subscribe fi - + if [ "${SUB_BY_PROXY}" == "0" ]; then # 先直连下载 echo_date "➡️通过本地网络直连下载订阅..." rm -f "${header_file}" >/dev/null 2>&1 - run /tmp/curl-subscribe -sSk -L ${UA_ARG} -D "${header_file}" --connect-timeout 5 -m 5 --retry 3 --retry-delay 1 "${url_encode}" 2>/dev/null >${DIR}/sub_file_encode_${SUB_LINK_HASH:0:4}.txt + run /tmp/curl-subscribe -sSk -L "$@" -D "${header_file}" --connect-timeout 5 -m 5 --retry 3 --retry-delay 1 "${url_encode}" 2>/dev/null >${DIR}/sub_file_encode_${SUB_LINK_HASH:0:4}.txt if [ "$?" == "0" ]; then return 0 fi @@ -6568,7 +6568,7 @@ download_by_curl(){ if [ -n "${SOCKS5_OPEN}" ];then echo_date "✈️使用当前$(get_type_name "$(sub_get_node_field_plain "${CURR_NODE}" type)")节点:[$(sub_get_node_field_plain "${CURR_NODE}" name)]提供的网络下载..." rm -f "${header_file}" >/dev/null 2>&1 - run /tmp/curl-subscribe -sSk -L ${UA_ARG} -D "${header_file}" --connect-timeout 5 -m 5 -x socks5h://127.0.0.1:23456 --retry 3 --retry-delay 1 "${url_encode}" 2>/dev/null >${DIR}/sub_file_encode_${SUB_LINK_HASH:0:4}.txt + run /tmp/curl-subscribe -sSk -L "$@" -D "${header_file}" --connect-timeout 5 -m 5 -x socks5h://127.0.0.1:23456 --retry 3 --retry-delay 1 "${url_encode}" 2>/dev/null >${DIR}/sub_file_encode_${SUB_LINK_HASH:0:4}.txt return $? else echo_date "⚠️当前$(get_type_name "$(sub_get_node_field_plain "${CURR_NODE}" type)")节点工作异常,结束curl订阅下载!" @@ -6581,7 +6581,7 @@ download_by_curl(){ local EXT_ARG="-x socks5h://127.0.0.1:23456" echo_date "✈️使用当前$(get_type_name "$(sub_get_node_field_plain "${CURR_NODE}" type)")节点:[$(sub_get_node_field_plain "${CURR_NODE}" name)]提供的网络下载..." rm -f "${header_file}" >/dev/null 2>&1 - run /tmp/curl-subscribe -sSk -L ${UA_ARG} -D "${header_file}" --connect-timeout 5 -m 5 -x socks5h://127.0.0.1:23456 --retry 3 --retry-delay 1 "${url_encode}" 2>/dev/null >${DIR}/sub_file_encode_${SUB_LINK_HASH:0:4}.txt + run /tmp/curl-subscribe -sSk -L "$@" -D "${header_file}" --connect-timeout 5 -m 5 -x socks5h://127.0.0.1:23456 --retry 3 --retry-delay 1 "${url_encode}" 2>/dev/null >${DIR}/sub_file_encode_${SUB_LINK_HASH:0:4}.txt return $? else local EXT_ARG="" @@ -6592,7 +6592,7 @@ download_by_curl(){ # 直连下载 echo_date "⬇️使用常规网络下载..." rm -f "${header_file}" >/dev/null 2>&1 - run /tmp/curl-subscribe -sSk -L ${UA_ARG} -D "${header_file}" --connect-timeout 5 -m 5 --retry 3 --retry-delay 1 "${url_encode}" 2>/dev/null >${DIR}/sub_file_encode_${SUB_LINK_HASH:0:4}.txt + run /tmp/curl-subscribe -sSk -L "$@" -D "${header_file}" --connect-timeout 5 -m 5 --retry 3 --retry-delay 1 "${url_encode}" 2>/dev/null >${DIR}/sub_file_encode_${SUB_LINK_HASH:0:4}.txt return $? fi }