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) {
|
||||
if (Object.prototype.hasOwnProperty.call(groups, key)) {
|
||||
const group = groups[key];
|
||||
env_string += `export ${key}="${_(group)
|
||||
.filter((x) => x.status !== EnvStatus.disabled)
|
||||
.map('value')
|
||||
.join('&')
|
||||
.replace(/ /g, '')}"\n`;
|
||||
|
||||
// 忽略不符合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`;
|
||||
}
|
||||
}
|
||||
}
|
||||
fs.writeFileSync(config.envFile, env_string);
|
||||
|
|
|
@ -66,7 +66,11 @@ const CronModal = ({
|
|||
<Form.Item name="name" label="名称">
|
||||
<Input placeholder="请输入任务名称" />
|
||||
</Form.Item>
|
||||
<Form.Item name="command" label="命令" rules={[{ required: true }]}>
|
||||
<Form.Item
|
||||
name="command"
|
||||
label="命令"
|
||||
rules={[{ required: true, whitespace: true }]}
|
||||
>
|
||||
<Input.TextArea
|
||||
rows={4}
|
||||
autoSize={true}
|
||||
|
|
12
src/pages/env/modal.tsx
vendored
12
src/pages/env/modal.tsx
vendored
|
@ -74,7 +74,13 @@ const EnvModal = ({
|
|||
<Form.Item
|
||||
name="name"
|
||||
label="名称"
|
||||
rules={[{ required: true, message: '请输入环境变量名称' }]}
|
||||
rules={[
|
||||
{ required: true, message: '请输入环境变量名称', whitespace: true },
|
||||
{
|
||||
pattern: /^[a-zA-Z_][0-9a-zA-Z_]+$/,
|
||||
message: '只能输入字母数字下划线,且不能以数字开头',
|
||||
},
|
||||
]}
|
||||
>
|
||||
<Input placeholder="请输入环境变量名称" />
|
||||
</Form.Item>
|
||||
|
@ -89,7 +95,9 @@ const EnvModal = ({
|
|||
<Form.Item
|
||||
name="value"
|
||||
label="值"
|
||||
rules={[{ required: true, message: '请输入环境变量值' }]}
|
||||
rules={[
|
||||
{ required: true, message: '请输入环境变量值', whitespace: true },
|
||||
]}
|
||||
>
|
||||
<Input.TextArea
|
||||
rows={4}
|
||||
|
|
Loading…
Reference in New Issue
Block a user