修正跨平台字符处理统一

(cherry picked from commit 6e986a9c9cacfd00102cbe91f695c2253598560b)
This commit is contained in:
Rust 2025-10-29 11:42:44 +08:00 committed by speakeloudest
parent fde4bfa464
commit 3328919f7e

View File

@ -313,8 +313,8 @@ jobs:
echo " OSS: $OSS_URL_1"
echo " 密钥: ${ENCRYPTION_KEY:0:10}..."
# 转义密钥中的特殊字符
ENCRYPTION_KEY_ESCAPED=$(echo "$ENCRYPTION_KEY" | sed 's/[[.*^$()+?{|]/\\&/g')
# 转义密钥中的特殊字符(使用 perl 兼容所有平台)
ENCRYPTION_KEY_ESCAPED=$(echo "$ENCRYPTION_KEY" | perl -pe 's/([\[\].*^$()+?{|\\])/\\$1/g')
sed -i "s|api\.maodag\.top|$API_DOMAIN|g" "$CONFIG_FILE"
sed -i "s|https://ppp2\.oss-cn-hongkong\.aliyuncs\.com/bear1\.txt|$OSS_URL_1|g" "$CONFIG_FILE"
@ -426,7 +426,7 @@ jobs:
OSS_URL_4="${{ inputs.oss_url_4 || 'https://xpp5.oss-ap-southeast-1.aliyuncs.com/bear1.txt' }}"
ENCRYPTION_KEY="${{ inputs.encryption_key || 'c0qhq99a-nq8h-ropg-wrlc-ezj4dlkxqpzx' }}"
ENCRYPTION_KEY_ESCAPED=$(echo "$ENCRYPTION_KEY" | sed 's/[[.*^$()+?{|]/\\&/g')
ENCRYPTION_KEY_ESCAPED=$(echo "$ENCRYPTION_KEY" | perl -pe 's/([\[\].*^$()+?{|\\])/\\$1/g')
sed -i "s|api\.maodag\.top|$API_DOMAIN|g" "$CONFIG_FILE"
sed -i "s|https://ppp2\.oss-cn-hongkong\.aliyuncs\.com/bear1\.txt|$OSS_URL_1|g" "$CONFIG_FILE"
@ -523,15 +523,25 @@ jobs:
OSS_URL_4="${{ inputs.oss_url_4 || 'https://xpp5.oss-ap-southeast-1.aliyuncs.com/bear1.txt' }}"
ENCRYPTION_KEY="${{ inputs.encryption_key || 'c0qhq99a-nq8h-ropg-wrlc-ezj4dlkxqpzx' }}"
# macOS 使用不同的 sed 语法,需要转义
ENCRYPTION_KEY_ESCAPED=$(echo "$ENCRYPTION_KEY" | sed 's/[[.*^$()+?{|]/\\&/g')
# macOS 使用 BSD sed转义特殊字符
# 使用 perl 来转义特殊字符,更可靠
ENCRYPTION_KEY_ESCAPED=$(echo "$ENCRYPTION_KEY" | perl -pe 's/([\[\].*^$()+?{|\\])/\\$1/g')
echo "🔧 配置参数:"
echo " API: $API_DOMAIN"
echo " 密钥: ${ENCRYPTION_KEY:0:10}..."
# macOS sed 需要使用 -i '' 和正确的语法
sed -i '' "s|api\.maodag\.top|$API_DOMAIN|g" "$CONFIG_FILE"
sed -i '' "s|https://ppp2\.oss-cn-hongkong\.aliyuncs\.com/bear1\.txt|$OSS_URL_1|g" "$CONFIG_FILE"
sed -i '' "s|https://xgp3\.oss-ap-northeast-1\.aliyuncs\.com/bear1\.txt|$OSS_URL_2|g" "$CONFIG_FILE"
sed -i '' "s|https://xpp4\.oss-ap-northeast-2\.aliyuncs\.com/bear1\.txt|$OSS_URL_3|g" "$CONFIG_FILE"
sed -i '' "s|https://xpp5\.oss-ap-southeast-1\.aliyuncs\.com/bear1\.txt|$OSS_URL_4|g" "$CONFIG_FILE"
# 使用不同的分隔符避免转义问题
sed -i '' "s|c0qhq99a-nq8h-ropg-wrlc-ezj4dlkxqpzx|$ENCRYPTION_KEY_ESCAPED|g" "$CONFIG_FILE"
echo "✅ 配置完成"
- name: 📦 安装 Flutter 依赖
run: |
@ -611,7 +621,7 @@ jobs:
OSS_URL_4="${{ inputs.oss_url_4 || 'https://xpp5.oss-ap-southeast-1.aliyuncs.com/bear1.txt' }}"
ENCRYPTION_KEY="${{ inputs.encryption_key || 'c0qhq99a-nq8h-ropg-wrlc-ezj4dlkxqpzx' }}"
ENCRYPTION_KEY_ESCAPED=$(echo "$ENCRYPTION_KEY" | sed 's/[[.*^$()+?{|]/\\&/g')
ENCRYPTION_KEY_ESCAPED=$(echo "$ENCRYPTION_KEY" | perl -pe 's/([\[\].*^$()+?{|\\])/\\$1/g')
sed -i "s|api\.maodag\.top|$API_DOMAIN|g" "$CONFIG_FILE"
sed -i "s|https://ppp2\.oss-cn-hongkong\.aliyuncs\.com/bear1\.txt|$OSS_URL_1|g" "$CONFIG_FILE"