fix: 更新订阅链接时,支持带空格的UA - #33810
Open
niurenpeng wants to merge 1 commit into
Open
Conversation
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) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
download_by_curl把 UA 拼进UA_ARG后以不带引号的形式展开,ClashX 这类含空格/括号的 UA 会被 word-split 成多个 token,
真正发出去的
User-Agent只剩首个 token,其余碎片被 curl 当成额外 URL 请求,导致订阅更新 404。
set -- --user-agent "${UA}"/set --,在 curl 调用处用
"$@"展开,保证 UA 作为单个完整参数传入。url_encode在set --之前已存入局部变量,订阅链接不会丢。download_by_wget存在同样 bug,本 PR 暂不一并修改,先验证 curl 路径。Test plan
/koolshare/scripts/ss_node_subscribe.sh后,在 Web UI 触发"更新订阅"🪧 使用UA:完整打印ClashX/1.125.0 (com.west2online.ClashX; build:1.125.0; macOS 26.3.1) Alamofire/5.11.2