fix: update.sh nginx补丁修正Python中文字面量
这个提交包含在:
父节点
65858594e7
当前提交
28fdd0ed78
@ -513,18 +513,19 @@ _nginx_conf="$ROOT_DIR/config/nginx/conf.d/xuqm.conf"
|
|||||||
if [ -f "$_nginx_conf" ] && ! grep -q 'api/auth/register' "$_nginx_conf"; then
|
if [ -f "$_nginx_conf" ] && ! grep -q 'api/auth/register' "$_nginx_conf"; then
|
||||||
_PATCH_PY="$(mktemp /tmp/xuqm-nginx-patch-XXXXXX.py)"
|
_PATCH_PY="$(mktemp /tmp/xuqm-nginx-patch-XXXXXX.py)"
|
||||||
cat > "$_PATCH_PY" << 'NGINX_PATCH_PY'
|
cat > "$_PATCH_PY" << 'NGINX_PATCH_PY'
|
||||||
|
# -*- coding: utf-8 -*-
|
||||||
import re, sys
|
import re, sys
|
||||||
path = sys.argv[1]
|
path = sys.argv[1]
|
||||||
content = open(path).read()
|
content = open(path, encoding='utf-8').read()
|
||||||
block = (
|
block = (
|
||||||
' # \u79c佖化部署:精确拦截用户自注册(必须在通用 /api/ 之前)\n'
|
' # 私有化部署:精确拦截用户自注册(必须在通用 /api/ 之前)\n'
|
||||||
' location = /api/auth/register {\n'
|
' location = /api/auth/register {\n'
|
||||||
" add_header Content-Type 'application/json; charset=utf-8' always;\n"
|
" add_header Content-Type 'application/json; charset=utf-8' always;\n"
|
||||||
' return 403 \'{"code":403,"status":"1","data":null,"message":"\u79c佖化部署已禁用用户自注册"}\';\n'
|
" return 403 '{\"code\":403,\"status\":\"1\",\"data\":null,\"message\":\"私有化部署已禁用用户自注册\"}';\n"
|
||||||
' }\n\n'
|
' }\n\n'
|
||||||
)
|
)
|
||||||
content = re.sub(r'( # 核心 API)', block + r'\1', content, count=1)
|
content = re.sub(r'( # 核心 API)', block + r'\1', content, count=1)
|
||||||
open(path, 'w').write(content)
|
open(path, 'w', encoding='utf-8').write(content)
|
||||||
NGINX_PATCH_PY
|
NGINX_PATCH_PY
|
||||||
python3 "$_PATCH_PY" "$_nginx_conf" && ok "nginx conf 已补充用户注册拦截规则" || warn "nginx conf 修改失败,请手动添加"
|
python3 "$_PATCH_PY" "$_nginx_conf" && ok "nginx conf 已补充用户注册拦截规则" || warn "nginx conf 修改失败,请手动添加"
|
||||||
rm -f "$_PATCH_PY"
|
rm -f "$_PATCH_PY"
|
||||||
|
|||||||
正在加载...
在新工单中引用
屏蔽一个用户