避免环境变量中出现"字符的时候提前截断字符串

This commit is contained in:
雪狐 2021-11-28 18:10:14 +08:00 committed by GitHub
parent e129485285
commit b7a04b36f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -219,11 +219,19 @@ export default class EnvService {
// 忽略不符合bash要求的环境变量名称
if (/^[a-zA-Z_][0-9a-zA-Z_]+$/.test(key)) {
env_string += `export ${key}="${_(group)
.filter((x) => x.status !== EnvStatus.disabled)
.map('value')
.join('&')
.replace(/ /g, '')}"\n`;
if (/"/.test(_(group).map('value').join('&'))) {
env_string += `export ${key}='${_(group)
.filter((x) => x.status !== EnvStatus.disabled)
.map('value')
.join('&')
.replace(/ /g, '')}'\n`;
} else {
env_string += `export ${key}="${_(group)
.filter((x) => x.status !== EnvStatus.disabled)
.map('value')
.join('&')
.replace(/ /g, '')}"\n`;
}
}
}
}