vernesong / OpenClash

A Clash Client For OpenWrt
MIT License
16.81k stars 3.1k forks source link

[Bug] urlencode函数返回空导致第三方规则更新了错误的内容 #2811

Closed wxy1343 closed 1 year ago

wxy1343 commented 1 year ago

Verify Steps

OpenClash Version

v0.45.70-beta

Bug on Environment

Lean

Bug on Platform

Linux-amd64(x86-64)

To Reproduce

游戏规则列表第三方规则集列表点击更新规则

Describe the Bug

https://github.com/vernesong/OpenClash/blob/e475a5d3bc05fdf60ab1c8d24432122684451701/luci-app-openclash/root/usr/share/openclash/openclash_download_rule_list.sh#L5-L13 curl执行完没有任何输出 https://github.com/vernesong/OpenClash/blob/e475a5d3bc05fdf60ab1c8d24432122684451701/luci-app-openclash/root/usr/share/openclash/openclash_download_rule_list.sh#L8 DOWNLOAD_PATH被赋予空值 https://github.com/vernesong/OpenClash/blob/e475a5d3bc05fdf60ab1c8d24432122684451701/luci-app-openclash/root/usr/share/openclash/openclash_download_rule_list.sh#L67

OpenClash Log


OpenClash Config

No response

Expected Behavior


Screenshots

image

vernesong commented 1 year ago

你curl正常吗

wxy1343 commented 1 year ago

你curl正常吗

其它功能都是正常的

root@OpenWrt:~# curl --version
curl 7.86.0 (x86_64-openwrt-linux-gnu) libcurl/7.86.0 mbedTLS/2.28.1 nghttp2/1.44.0
Release-Date: 2022-10-26
Protocols: file ftp ftps http https mqtt
Features: alt-svc HSTS HTTP2 IPv6 Largefile SSL threadsafe
vernesong commented 1 year ago

curl -sS -o /dev/null -w %{url_effective} --get --data-urlencode "key=TEST" ""

wxy1343 commented 1 year ago

curl -sS -o /dev/null -w %{url_effective} --get --data-urlencode "key=TEST" ""

image

vernesong commented 1 year ago

curl -sS -o /dev/null -w %{url_effective} "www.baidu.com"

wxy1343 commented 1 year ago

curl -sS -o /dev/null -w %{url_effective} "www.baidu.com"

image

wxy1343 commented 1 year ago

应该是更新curl后出现的问题,旧版本正常,已测试v7.86.0出现该问题

mouseroser commented 1 year ago

https://github.com/vernesong/OpenClash/issues/2799#issue-1439435989,已给出解决方案且已通过验证,curl及openclash均使用最新版本

在不回滚curl 7.86.0之前版本解决方案如下: vim /usr/share/openclash/openclash.sh 39行,使用以下代码替换原有urlencode()方法代码即可:

urlencode() { 
    local string="${1}"
    local strlen=${#string}
    local encoded=""
    local pos c o

    for (( pos=0 ; pos<strlen ; pos++ )); do
       c=${string:$pos:1}
       case "$c" in
       [-_.~a-zA-Z0-9] ) o="${c}" ;;
       * ) printf -v o '%%%02x' "'$c"
       esac
       encoded+="${o}"
   done

   echo "${encoded}" # You can either set a return variable (FASTER)
   REPLY="${encoded}" #+or echo the result (EASIER)... both... :p
}
mouseroser commented 1 year ago

应该是更新curl后出现的问题,旧版正常,已经测试v7.86.0出现该问题

已在楼上给出解决方案

abc9878 commented 1 year ago

https://github.com/vernesong/OpenClash/issues/2799#issue-1439435989,已给出解决方案且已通过验证,curl及openclash均使用最新版本

在不回滚curl 7.86.0之前版本解决方案如下: vim /usr/share/openclash/openclash.sh 39行,使用以下代码替换原有urlencode()方法代码即可:

urlencode() { 
    local string="${1}"
    local strlen=${#string}
    local encoded=""
    local pos c o

    for (( pos=0 ; pos<strlen ; pos++ )); do
       c=${string:$pos:1}
       case "$c" in
       [-_.~a-zA-Z0-9] ) o="${c}" ;;
       * ) printf -v o '%%%02x' "'$c"
       esac
       encoded+="${o}"
   done

   echo "${encoded}" # You can either set a return variable (FASTER)
   REPLY="${encoded}" #+or echo the result (EASIER)... both... :p
}

额,在线订阅转换也因为curl出错了。用你这个方法后,排除节点失效了

vernesong commented 1 year ago

dev

github-actions[bot] commented 1 year ago

This issue is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 5 days