Skip to content
Snippets Groups Projects
Unverified Commit f4349f9a authored by 曹华栋's avatar 曹华栋 Committed by GitHub
Browse files

bugfix: fix the value can not be push to nacos when special charset in config.txt (#3406)

parent ee18dad4
No related branches found
No related tags found
No related merge requests found
......@@ -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
......
......@@ -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:
......
......@@ -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()
......
......@@ -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
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment