mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-23 14:56:07 +08:00
修复环境变量名称验证
This commit is contained in:
parent
ff44330aa1
commit
d44a8966f2
|
@ -39,7 +39,9 @@ export default (app: Router) => {
|
||||||
body: Joi.array().items(
|
body: Joi.array().items(
|
||||||
Joi.object({
|
Joi.object({
|
||||||
value: Joi.string().required(),
|
value: Joi.string().required(),
|
||||||
name: Joi.string().required(),
|
name: Joi.string()
|
||||||
|
.required()
|
||||||
|
.pattern(/^[a-zA-Z_][0-9a-zA-Z_]*$/),
|
||||||
remarks: Joi.string().optional().allow(''),
|
remarks: Joi.string().optional().allow(''),
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
|
|
|
@ -158,7 +158,7 @@ export default class EnvService {
|
||||||
const envs = await this.envs(
|
const envs = await this.envs(
|
||||||
'',
|
'',
|
||||||
{ position: -1 },
|
{ position: -1 },
|
||||||
{ name: { [Op.not]: null } },
|
{ name: { [Op.not]: null }, status: EnvStatus.normal },
|
||||||
);
|
);
|
||||||
const groups = _.groupBy(envs, 'name');
|
const groups = _.groupBy(envs, 'name');
|
||||||
let env_string = '';
|
let env_string = '';
|
||||||
|
@ -167,9 +167,8 @@ export default class EnvService {
|
||||||
const group = groups[key];
|
const group = groups[key];
|
||||||
|
|
||||||
// 忽略不符合bash要求的环境变量名称
|
// 忽略不符合bash要求的环境变量名称
|
||||||
if (/^[a-zA-Z_][0-9a-zA-Z_]+$/.test(key)) {
|
if (/^[a-zA-Z_][0-9a-zA-Z_]*$/.test(key)) {
|
||||||
let value = _(group)
|
let value = _(group)
|
||||||
.filter((x) => x.status !== EnvStatus.disabled)
|
|
||||||
.map('value')
|
.map('value')
|
||||||
.join('&')
|
.join('&')
|
||||||
.replace(/(\\)[^n]/g, '\\\\')
|
.replace(/(\\)[^n]/g, '\\\\')
|
||||||
|
|
Loading…
Reference in New Issue
Block a user