diff --git a/changes/1.5.0.md b/changes/1.5.0.md index 60495cf595375587bb248dbc40dc2af08312f174..364bd827615260db8873018f1bd9202007a5f95f 100644 --- a/changes/1.5.0.md +++ b/changes/1.5.0.md @@ -26,6 +26,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单 - [[#3258](https://github.com/seata/seata/pull/3258)] 修复AsyncWorker潜在的OOM问题 - [[#3293](https://github.com/seata/seata/pull/3293)] 修复配置缓存获取值时类型不匹配的bug - [[#3241](https://github.com/seata/seata/pull/3241)] 禁止在多SQL的情况下使用 limit 和 order by 语法 + - [[#3406](https://github.com/seata/seata/pull/3406)] 修复当config.txt中包含特殊字符时,键值对无法被推上nacos diff --git a/changes/en-us/1.5.0.md b/changes/en-us/1.5.0.md index 45ff694fc786952fe86728732aa0532029b0b0d2..5fbe1f8ac81dd5e6477289aa101bb06e8c653fc1 100644 --- a/changes/en-us/1.5.0.md +++ b/changes/en-us/1.5.0.md @@ -26,6 +26,7 @@ - [[#3258](https://github.com/seata/seata/pull/3258)] fix AsyncWorker potential OOM problem - [[#3293](https://github.com/seata/seata/pull/3293)] configuration cache get value cast exception - [[#3241](https://github.com/seata/seata/pull/3241)] forbidden use order by or limit in multi sql + - [[#3406](https://github.com/seata/seata/pull/3406)] fix the value can not be push to nacos when special charset in config.txt ### optimize: diff --git a/script/config-center/nacos/nacos-config.py b/script/config-center/nacos/nacos-config.py index 014caf18320152199f3a33c811d49f4f04a38688..7d41dd13b64e080bff3a0f4b8d13034cb914d42f 100644 --- a/script/config-center/nacos/nacos-config.py +++ b/script/config-center/nacos/nacos-config.py @@ -3,6 +3,7 @@ import http.client import sys +import urllib.parse if len(sys.argv) <= 2: print ('python nacos-config.py nacosAddr') @@ -14,7 +15,7 @@ headers = { hasError = False for line in open('../config.txt'): - pair = line.split('=') + pair = line.rstrip("\n").split('=') if len(pair) < 2: continue print (line), @@ -22,9 +23,9 @@ for line in open('../config.txt'): conn = http.client.HTTPConnection(url_prefix) if len(sys.argv) == 3: namespace=sys.argv[2] - url_postfix = '/nacos/v1/cs/configs?dataId={0}&group=SEATA_GROUP&content={1}&tenant={2}'.format(str(pair[0]),str(line[line.index('=')+1:]).strip(),namespace) + url_postfix = '/nacos/v1/cs/configs?dataId={0}&group=SEATA_GROUP&content={1}&tenant={2}'.format(urllib.parse.quote(str(pair[0])),urllib.parse.quote(str(pair[1])).strip(),namespace) else: - url_postfix = '/nacos/v1/cs/configs?dataId={}&group=SEATA_GROUP&content={}'.format(str(pair[0]),str(line[line.index('=')+1:])).strip() + url_postfix = '/nacos/v1/cs/configs?dataId={}&group=SEATA_GROUP&content={}'.format(urllib.parse.quote(str(pair[0])),urllib.parse.quote(str(pair[1]))).strip() conn.request("POST", url_postfix, headers=headers) res = conn.getresponse() data = res.read() diff --git a/script/config-center/nacos/nacos-config.sh b/script/config-center/nacos/nacos-config.sh index 0f47b52e851e88059f12b8cd3abc33af1dab102f..a2f7be91c535c84c20ab11603f712b2c9ab1c572 100644 --- a/script/config-center/nacos/nacos-config.sh +++ b/script/config-center/nacos/nacos-config.sh @@ -41,6 +41,17 @@ do esac done +urlencode() { + for ((i=0; i < ${#1}; i++)) + do + char="${1:$i:1}" + case $char in + [a-zA-Z0-9.~_-]) printf $char ;; + *) printf '%%%02X' "'$char" ;; + esac + done +} + if [[ -z ${host} ]]; then host=localhost fi @@ -69,7 +80,7 @@ echo "set group=$group" failCount=0 tempLog=$(mktemp -u) function addConfig() { - curl -X POST -H "${contentType}" "http://$nacosAddr/nacos/v1/cs/configs?dataId=$1&group=$group&content=$2&tenant=$tenant&username=$username&password=$password" >"${tempLog}" 2>/dev/null + curl -X POST -H "${contentType}" "http://$nacosAddr/nacos/v1/cs/configs?dataId=$(urlencode $1)&group=$group&content=$(urlencode $2)&tenant=$tenant&username=$username&password=$password" >"${tempLog}" 2>/dev/null if [[ -z $(cat "${tempLog}") ]]; then echo " Please check the cluster status. " exit 1