diff --git a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java index 6eb802619f..4c9ad3cb58 100644 --- a/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java +++ b/designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java @@ -26,6 +26,7 @@ import com.fr.design.gui.itableeditorpane.UITableEditorPane; import com.fr.design.gui.itextfield.UITextField; import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; +import com.fr.design.i18n.Toolkit; import com.fr.design.layout.FRGUIPaneFactory; import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayoutHelper; @@ -612,7 +613,7 @@ public class FileTableDataPane extends AbstractTableDataPane { private void setTextField(FileTableData ob) { if (ob.getFilePath() != null) { - if (ob.getFilePath().indexOf("http") != -1) { + if (ob.getFilePath().contains("http")) { urlRadioSelectAction(); urlText.setText(ob.getFilePath()); } else { @@ -625,6 +626,15 @@ public class FileTableDataPane extends AbstractTableDataPane { @Override public FileTableData updateBean() { String filePath = getFilePathFromUrlOrLocal(); + // 安全要求禁止 file 协议访问本地磁盘 + if (FileTableData.isInvalidFilePath(filePath)) { + JOptionPane.showMessageDialog(this, + Toolkit.i18nText("Fine-Design_File_Table_Data_Path_Invalid"), + Toolkit.i18nText("Fine-Design_Basic_Widget_Error_Tip"), + JOptionPane.ERROR_MESSAGE); + // 阻止对话框关闭 + throw new RuntimeException(Toolkit.i18nText("Fine-Design_File_Table_Data_Path_Invalid")); + } if (StringUtils.isNotBlank(filePath)) { this.params = getEditorPaneParameter().length == 0 ? null : getEditorPaneParameter(); if (fileTypeComboBox.getSelectedIndex() == EXCEL) { @@ -786,6 +796,14 @@ public class FileTableDataPane extends AbstractTableDataPane { if (this.fileTableData == null) { return; } + String filePath = getFilePathFromUrlOrLocal(); + if (FileTableData.isInvalidFilePath(filePath)) { + JOptionPane.showMessageDialog(this, + Toolkit.i18nText("Fine-Design_File_Table_Data_Path_Invalid"), + Toolkit.i18nText("Fine-Design_Basic_Widget_Error_Tip"), + JOptionPane.ERROR_MESSAGE); + return; + } PreviewTablePane.previewTableData(this.updateBean()); } @@ -802,7 +820,7 @@ public class FileTableDataPane extends AbstractTableDataPane { xmlNodeTree = new XMLNodeTree(); this.add(new JScrollPane(xmlNodeTree)); - keyPointLaber = new UILabel(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Key_Point") + ":"); + keyPointLaber = new UILabel(Toolkit.i18nText("Fine-Design_Basic_Key_Point") + ":"); refreshAction = new RefreshParameterAction(); ToolBarDef toolbarDef = new ToolBarDef(); toolbarDef.addShortCut(refreshAction); @@ -820,7 +838,7 @@ public class FileTableDataPane extends AbstractTableDataPane { private class RefreshParameterAction extends UpdateAction { public RefreshParameterAction() { - this.setName(com.fr.design.i18n.Toolkit.i18nText("Fine-Design_Basic_Refresh")); + this.setName(Toolkit.i18nText("Fine-Design_Basic_Refresh")); this.setMnemonic('r'); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); }