diff --git a/src/modules/components/file_chooser/file_chooser.ts b/src/modules/components/file_chooser/file_chooser.ts index 634cfdb..dc430d1 100644 --- a/src/modules/components/file_chooser/file_chooser.ts +++ b/src/modules/components/file_chooser/file_chooser.ts @@ -41,7 +41,7 @@ export class FileChooser extends BI.Widget { items: [ { type: BI.SignEditor.xtype, - cls: 'bi-border bi-focus-shadow', + cls: 'bi-border-bottom bi-focus-shadow', width, height: 22, watermark, diff --git a/src/modules/components/file_upload/file_upload.ts b/src/modules/components/file_upload/file_upload.ts index 01892c0..9a4f62f 100644 --- a/src/modules/components/file_upload/file_upload.ts +++ b/src/modules/components/file_upload/file_upload.ts @@ -59,7 +59,7 @@ export class FileUpload extends BI.Widget { items: [ { type: BI.SignEditor.xtype, - cls: 'bi-border bi-focus-shadow', + cls: 'bi-border-bottom bi-focus-shadow', width: 300, height: 22, watermark, @@ -144,9 +144,9 @@ export class FileUpload extends BI.Widget { this.fileModified = _ref; }, }] - + }], - + }, tgap: 14, lgap: 4, @@ -155,7 +155,7 @@ export class FileUpload extends BI.Widget { type: BI.IconButton.xtype, cls: "default-delete-font", handler: function () { - NProgress.set(0.0); + NProgress.set(0.0); self.xhr.abort(); self.store.setFileName(''); self.clearInfo(); diff --git a/src/modules/components/test_status/tip_icon/tip_fail.ts b/src/modules/components/test_status/tip_icon/tip_fail.ts index f8a77f3..576580e 100644 --- a/src/modules/components/test_status/tip_icon/tip_fail.ts +++ b/src/modules/components/test_status/tip_icon/tip_fail.ts @@ -54,8 +54,7 @@ export class TipFail extends BI.Widget { }], }, { type: BI.Label.xtype, - height: 14, - bgap: 10, + _bgap: 10, text: tipText, ref:(_ref:Label)=>{ this.failText=_ref; @@ -63,12 +62,12 @@ export class TipFail extends BI.Widget { }, { type: BI.VerticalAdaptLayout.xtype, - hgap: 5, + hgap: 12, items: [ { type: BI.Button.xtype, text: BI.i18nText('Dec-Dcm_Connection_Detailed_Information'), - level: 'ignore', + clear: true, ref: (_ref: Button) => { this.detailButton = _ref; }, @@ -79,8 +78,8 @@ export class TipFail extends BI.Widget { }, { type: BI.Button.xtype, + light: true, text: BI.i18nText('Dec-Dcm_Back'), - level: 'ignore', handler: () => { this.fireEvent(TipFail.EVENT_CLOSE); }, diff --git a/src/modules/core/checkIllegalStrings/checkIllegalStrings.ts b/src/modules/core/checkIllegalStrings/checkIllegalStrings.ts new file mode 100644 index 0000000..696d8fb --- /dev/null +++ b/src/modules/core/checkIllegalStrings/checkIllegalStrings.ts @@ -0,0 +1,44 @@ +/* + https://work.fineres.com/browse/REPORT-91724 用于参数统一校验 + */ +import { ILLEGAL_STRINGS } from "./constant"; +export type CheckResult = { + legal: boolean, + errorMsg: string, +} +export const CHECK_CORRECT: CheckResult = { + legal: true, + errorMsg: "", +}; + +/** + * 检测非法字符,返回错误提示 + * @param value 要校验的字符串 + */ +export function checkIllegalStrings(value: string): CheckResult { + // 后端传入的校验开关,如果没传,那也默认开启 + const enabled = Dec.system.enableParameterVerify ?? true; + if (enabled) { + const illegalStringIndex = ILLEGAL_STRINGS.findIndex(s => value.includes(s)); + if (illegalStringIndex === -1) { + return CHECK_CORRECT; + } + + return { + legal: false, + errorMsg: `${BI.i18nText("Dec-Basic_Check_Illegal_Strings")}${ILLEGAL_STRINGS[illegalStringIndex]}`, + }; + } + + return CHECK_CORRECT; +} + +export function checkIllegalStringsInWidgetAndShowError(widget: any) { + const value = widget.getValue(); + const result = checkIllegalStrings(value); + if (!result.legal) { + widget.showError(result.errorMsg); + } + + return result.legal; +} diff --git a/src/modules/core/checkIllegalStrings/constant.ts b/src/modules/core/checkIllegalStrings/constant.ts new file mode 100644 index 0000000..a034a3f --- /dev/null +++ b/src/modules/core/checkIllegalStrings/constant.ts @@ -0,0 +1,15 @@ +/** + * 参数检验的非法字符数组 + */ +export const ILLEGAL_STRINGS = [ + "\"", + "<", + ">", + "&", + "/script", + "javascript:", + "onblur", + "getRuntime", + "ProcessBuilder", + "java.lang.ProcessImpl", +]; diff --git a/src/modules/core/index.ts b/src/modules/core/index.ts new file mode 100644 index 0000000..efe056c --- /dev/null +++ b/src/modules/core/index.ts @@ -0,0 +1 @@ +export { checkIllegalStringsInWidgetAndShowError, checkIllegalStrings } from "./checkIllegalStrings/checkIllegalStrings" diff --git a/src/modules/pages/connection/connection.ts b/src/modules/pages/connection/connection.ts index 90f5ba1..881759d 100644 --- a/src/modules/pages/connection/connection.ts +++ b/src/modules/pages/connection/connection.ts @@ -143,7 +143,6 @@ export class Connection extends BI.Widget { }, }], }, - width: 90, }, ], }, diff --git a/src/modules/pages/connection/list/list_item/list_item.ts b/src/modules/pages/connection/list/list_item/list_item.ts index 60736d3..e61114c 100644 --- a/src/modules/pages/connection/list/list_item/list_item.ts +++ b/src/modules/pages/connection/list/list_item/list_item.ts @@ -7,6 +7,7 @@ import { connectionCanEdit, getTextByDatabaseType, getChartLength } from '../../ import { testConnection } from '../../../maintain/forms/form.server'; import { DownListCombo, Label, SignEditor } from '@fui/core'; import { ApiFactory } from '../../../../crud/apiFactory'; +import { checkIllegalStrings } from "@core/index"; const api = new ApiFactory().create(); @@ -89,6 +90,17 @@ export class ListItem extends BI.BasicButton { return; } + const result = checkIllegalStrings(newName); + if (!result.legal) { + BI.Msg.toast(result.errorMsg, { + level: 'error', + }); + this.store.setIsEdit(false, name); + this.nameLabel.setText(name); + this.nameEditor.setValue(name); + + return; + } this.store.changeName(name, newName).then(re => { this.store.setIsEdit(false, name); if (re.errorCode) { diff --git a/src/modules/pages/maintain/forms/components/form.jdbc.ts b/src/modules/pages/maintain/forms/components/form.jdbc.ts index 7db6718..28aa75f 100644 --- a/src/modules/pages/maintain/forms/components/form.jdbc.ts +++ b/src/modules/pages/maintain/forms/components/form.jdbc.ts @@ -423,7 +423,7 @@ export class FormJdbc extends BI.Widget { { type: BI.Editor.xtype, $value: 'password', - cls: 'bi-border bi-border-radius', + cls: 'bi-border-bottom', width: EDITOR_WIDTH, height: EDITOR_HEIGHT, allowBlank: true, @@ -573,6 +573,7 @@ export class FormJdbc extends BI.Widget { forms: [ { type: BI.VerticalLayout.xtype, + height: 55, items: [ { type: BI.FloatLeftLayout.xtype, @@ -595,9 +596,9 @@ export class FormJdbc extends BI.Widget { }, { type: BI.TextValueCombo.xtype, + _tgap: 15, $value: 'schema', width: EDITOR_WIDTH, - tgap: 15, disabled: true, value: schema, items: schema ? [{ text: schema, value: schema }] : [], @@ -715,7 +716,7 @@ export class FormJdbc extends BI.Widget { { type: BI.Editor.xtype, $value: 'temporary-file-pieces-limit', - cls: 'bi-border bi-border-radius', + cls: 'bi-border-bottom', width: EDITOR_WIDTH, height: EDITOR_HEIGHT, allowBlank: true, @@ -735,7 +736,7 @@ export class FormJdbc extends BI.Widget { { type: BI.Editor.xtype, $value: 'temporary-file-size-limit', - cls: 'bi-border bi-border-radius', + cls: 'bi-border-bottom', width: EDITOR_WIDTH, height: EDITOR_HEIGHT, allowBlank: true, @@ -801,7 +802,7 @@ export class FormJdbc extends BI.Widget { { type: BI.Editor.xtype, $value: 'hdfs-connection-address', - cls: 'bi-border bi-border-radius', + cls: 'bi-border-bottom', width: EDITOR_WIDTH, height: EDITOR_HEIGHT, allowBlank: true, diff --git a/src/modules/pages/maintain/forms/form.ts b/src/modules/pages/maintain/forms/form.ts index 609b880..4039f81 100644 --- a/src/modules/pages/maintain/forms/form.ts +++ b/src/modules/pages/maintain/forms/form.ts @@ -8,6 +8,7 @@ import { ConnectionJDBC, Connection, ResultType } from 'src/modules/crud/crud.ty import { DEFAULT_JNDI_DATA, DEFAULT_JDBC_POOL, DATEBASE_FILTER_TYPE } from '@constants/constant'; import { getJdbcDatabaseType, getChartLength } from '../../../app.service'; import { NAME_MAX_LENGTH } from '../../../app.constant'; +import { checkIllegalStrings } from "@core/index"; @shortcut() @store(MaintainFormModel) @@ -209,6 +210,12 @@ export class MaintainForm extends BI.Widget { if (this.form.validation && !this.form.validation()) { return false; } + const result = checkIllegalStrings(value.connectionName); + if (!result.legal) { + this.setFromError(result.errorMsg); + + return false; + } return true; } diff --git a/src/modules/title/title_database/title_datebase.ts b/src/modules/title/title_database/title_datebase.ts index 1441d75..6541237 100644 --- a/src/modules/title/title_database/title_datebase.ts +++ b/src/modules/title/title_database/title_datebase.ts @@ -25,13 +25,13 @@ export class TitleDatabase extends BI.Widget { items: [{ type: BI.VerticalAdaptLayout.xtype, height: 40, - rgap: 5, + rgap: 16, items: [ { type: BI.Button.xtype, $value: 'title-database-cancel', text: BI.i18nText('BI-Basic_Cancel'), - level: 'ignore', + light: true, handler: () => { this.store.setPageIndex(PAGE_INDEX.CONNECTION); }, @@ -49,6 +49,7 @@ export class TitleDatabase extends BI.Widget { }, }, ], + _rgap: -16, }], }; } diff --git a/src/modules/title/title_maintain/title_maintain.ts b/src/modules/title/title_maintain/title_maintain.ts index 18fdc2c..9eed070 100644 --- a/src/modules/title/title_maintain/title_maintain.ts +++ b/src/modules/title/title_maintain/title_maintain.ts @@ -15,13 +15,13 @@ export class TitleMaintain extends BI.Widget { items: [{ type: BI.VerticalAdaptLayout.xtype, height: 40, - rgap: 5, + hgap: 16, items: [ { type: BI.Button.xtype, $value: 'title-maintain-cancel', text: BI.i18nText('BI-Basic_Cancel'), - level: 'ignore', + clear: true, handler: () => { this.store.setIsCopy(false); this.store.setPageIndex(PAGE_INDEX.CONNECTION); @@ -32,7 +32,7 @@ export class TitleMaintain extends BI.Widget { type: BI.Button.xtype, $value: 'title-maintain-connection-test', text: BI.i18nText('Dec-Dcm_Connection_Test'), - level: 'ignore', + light: true, handler: () => { this.store.setTestEvent(); }, @@ -47,6 +47,7 @@ export class TitleMaintain extends BI.Widget { }, }, ], + _hgap: -16, }], }; }