mirror of
https://github.com/whyour/qinglong.git
synced 2025-05-25 16:36:07 +08:00
增加环境变量名称正则校验
This commit is contained in:
parent
3b8cb43f02
commit
b4cd94f2d9
|
@ -222,11 +222,15 @@ export default class EnvService {
|
||||||
for (const key in groups) {
|
for (const key in groups) {
|
||||||
if (Object.prototype.hasOwnProperty.call(groups, key)) {
|
if (Object.prototype.hasOwnProperty.call(groups, key)) {
|
||||||
const group = groups[key];
|
const group = groups[key];
|
||||||
env_string += `export ${key}="${_(group)
|
|
||||||
.filter((x) => x.status !== EnvStatus.disabled)
|
// 忽略不符合bash要求的环境变量名称
|
||||||
.map('value')
|
if (/^[a-zA-Z_][0-9a-zA-Z_]+$/.test(key)) {
|
||||||
.join('&')
|
env_string += `export ${key}="${_(group)
|
||||||
.replace(/ /g, '')}"\n`;
|
.filter((x) => x.status !== EnvStatus.disabled)
|
||||||
|
.map('value')
|
||||||
|
.join('&')
|
||||||
|
.replace(/ /g, '')}"\n`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
fs.writeFileSync(config.envFile, env_string);
|
fs.writeFileSync(config.envFile, env_string);
|
||||||
|
|
|
@ -66,7 +66,11 @@ const CronModal = ({
|
||||||
<Form.Item name="name" label="名称">
|
<Form.Item name="name" label="名称">
|
||||||
<Input placeholder="请输入任务名称" />
|
<Input placeholder="请输入任务名称" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
<Form.Item name="command" label="命令" rules={[{ required: true }]}>
|
<Form.Item
|
||||||
|
name="command"
|
||||||
|
label="命令"
|
||||||
|
rules={[{ required: true, whitespace: true }]}
|
||||||
|
>
|
||||||
<Input.TextArea
|
<Input.TextArea
|
||||||
rows={4}
|
rows={4}
|
||||||
autoSize={true}
|
autoSize={true}
|
||||||
|
|
12
src/pages/env/modal.tsx
vendored
12
src/pages/env/modal.tsx
vendored
|
@ -74,7 +74,13 @@ const EnvModal = ({
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="name"
|
name="name"
|
||||||
label="名称"
|
label="名称"
|
||||||
rules={[{ required: true, message: '请输入环境变量名称' }]}
|
rules={[
|
||||||
|
{ required: true, message: '请输入环境变量名称', whitespace: true },
|
||||||
|
{
|
||||||
|
pattern: /^[a-zA-Z_][0-9a-zA-Z_]+$/,
|
||||||
|
message: '只能输入字母数字下划线,且不能以数字开头',
|
||||||
|
},
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Input placeholder="请输入环境变量名称" />
|
<Input placeholder="请输入环境变量名称" />
|
||||||
</Form.Item>
|
</Form.Item>
|
||||||
|
@ -89,7 +95,9 @@ const EnvModal = ({
|
||||||
<Form.Item
|
<Form.Item
|
||||||
name="value"
|
name="value"
|
||||||
label="值"
|
label="值"
|
||||||
rules={[{ required: true, message: '请输入环境变量值' }]}
|
rules={[
|
||||||
|
{ required: true, message: '请输入环境变量值', whitespace: true },
|
||||||
|
]}
|
||||||
>
|
>
|
||||||
<Input.TextArea
|
<Input.TextArea
|
||||||
rows={4}
|
rows={4}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user