Browse Source

Pull request #4961: REPORT-52641 文件数据集需要限制目录

Merge in DESIGN/design from ~VITO/c-design:release/10.0 to release/10.0

* commit 'e25091c0ccc7ecca11639784d1b40ad3e7ff170f':
  无jira任务 代码质量
  REPORT-52641 文件数据集需要限制目录
zheng-1641779399395
vito 3 years ago
parent
commit
530cc49960
  1. 24
      designer-base/src/main/java/com/fr/design/data/tabledata/tabledatapane/FileTableDataPane.java

24
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.itextfield.UITextField;
import com.fr.design.gui.itoolbar.UIToolbar; import com.fr.design.gui.itoolbar.UIToolbar;
import com.fr.design.gui.itree.refreshabletree.ExpandMutableTreeNode; 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.FRGUIPaneFactory;
import com.fr.design.layout.TableLayout; import com.fr.design.layout.TableLayout;
import com.fr.design.layout.TableLayoutHelper; import com.fr.design.layout.TableLayoutHelper;
@ -612,7 +613,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
private void setTextField(FileTableData ob) { private void setTextField(FileTableData ob) {
if (ob.getFilePath() != null) { if (ob.getFilePath() != null) {
if (ob.getFilePath().indexOf("http") != -1) { if (ob.getFilePath().contains("http")) {
urlRadioSelectAction(); urlRadioSelectAction();
urlText.setText(ob.getFilePath()); urlText.setText(ob.getFilePath());
} else { } else {
@ -625,6 +626,15 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
@Override @Override
public FileTableData updateBean() { public FileTableData updateBean() {
String filePath = getFilePathFromUrlOrLocal(); String filePath = getFilePathFromUrlOrLocal();
// 安全要求禁止 file 协议访问本地磁盘
if (FileTableData.isInvalidFilePath(filePath)) {
FineJOptionPane.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)) { if (StringUtils.isNotBlank(filePath)) {
this.params = getEditorPaneParameter().length == 0 ? null : getEditorPaneParameter(); this.params = getEditorPaneParameter().length == 0 ? null : getEditorPaneParameter();
if (fileTypeComboBox.getSelectedIndex() == EXCEL) { if (fileTypeComboBox.getSelectedIndex() == EXCEL) {
@ -786,6 +796,14 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
if (this.fileTableData == null) { if (this.fileTableData == null) {
return; return;
} }
String filePath = getFilePathFromUrlOrLocal();
if (FileTableData.isInvalidFilePath(filePath)) {
FineJOptionPane.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()); PreviewTablePane.previewTableData(this.updateBean());
} }
@ -802,7 +820,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
xmlNodeTree = new XMLNodeTree(); xmlNodeTree = new XMLNodeTree();
this.add(new JScrollPane(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(); refreshAction = new RefreshParameterAction();
ToolBarDef toolbarDef = new ToolBarDef(); ToolBarDef toolbarDef = new ToolBarDef();
toolbarDef.addShortCut(refreshAction); toolbarDef.addShortCut(refreshAction);
@ -820,7 +838,7 @@ public class FileTableDataPane extends AbstractTableDataPane<FileTableData> {
private class RefreshParameterAction extends UpdateAction { private class RefreshParameterAction extends UpdateAction {
public RefreshParameterAction() { 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.setMnemonic('r');
this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png")); this.setSmallIcon(BaseUtils.readIcon("/com/fr/design/images/control/refresh.png"));
} }

Loading…
Cancel
Save