Skip to content

fix: 更新订阅链接时,支持带空格的UA - #33810

Open
niurenpeng wants to merge 1 commit into
hq450:3.0from
niurenpeng:fix/subscribe-curl-ua-quoting
Open

fix: 更新订阅链接时,支持带空格的UA#33810
niurenpeng wants to merge 1 commit into
hq450:3.0from
niurenpeng:fix/subscribe-curl-ua-quoting

Conversation

@niurenpeng

Copy link
Copy Markdown

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_encodeset -- 之前已存入局部变量,订阅链接不会丢。
  • 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
  • 订阅返回不再是 404,节点能正常下发

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant