From 1ce7acea5936653ee56118a628143c2c95f05900 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Tue, 3 Jun 2025 16:38:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20[Bug]=E8=BF=9C=E7=A8=8Bexcel=E8=AE=A4?= =?UTF-8?q?=E8=AF=81=E6=97=B6=E5=AF=B9=E5=AF=86=E7=A0=81=E4=B8=AD=E7=9A=84?= =?UTF-8?q?=E7=89=B9=E6=AE=8A=E5=AD=97=E7=AC=A6=E9=9C=80=E8=A6=81=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E7=BC=96=E7=A0=81=20#16089?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dataease/datasource/provider/ExcelUtils.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/datasource/provider/ExcelUtils.java b/core/core-backend/src/main/java/io/dataease/datasource/provider/ExcelUtils.java index eb84e609f3..413cfb5ac2 100644 --- a/core/core-backend/src/main/java/io/dataease/datasource/provider/ExcelUtils.java +++ b/core/core-backend/src/main/java/io/dataease/datasource/provider/ExcelUtils.java @@ -32,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile; import java.io.*; import java.net.URL; import java.net.URLConnection; +import java.net.URLEncoder; import java.nio.charset.StandardCharsets; import java.util.*; import java.util.regex.Matcher; @@ -668,7 +669,7 @@ public class ExcelUtils { List fields = new ArrayList<>(); BufferedReader reader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)); String s = reader.readLine();// first line - if(StringUtils.isNotEmpty(s)){ + if (StringUtils.isNotEmpty(s)) { String[] split = s.split(","); for (int i = 0; i < split.length; i++) { String filedName = split[i]; @@ -765,10 +766,10 @@ public class ExcelUtils { DEException.throwException(Translator.get("i18n_invalid_address")); } } - if(StringUtils.isNotEmpty(remoteExcelRequest.getUserName())){ + if (StringUtils.isNotEmpty(remoteExcelRequest.getUserName())) { username = remoteExcelRequest.getUserName(); } - if(StringUtils.isNotEmpty(remoteExcelRequest.getPasswd())){ + if (StringUtils.isNotEmpty(remoteExcelRequest.getPasswd())) { password = remoteExcelRequest.getPasswd(); } filePath = filePath.startsWith("/") ? filePath.substring(1) : filePath; @@ -783,10 +784,10 @@ public class ExcelUtils { try { URL url; - if(StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(password)){ - url= new URL("ftp://" + username + ":" +password + "@" + serverAddress + "/" + filePath); - }else { - url= new URL("ftp://" + serverAddress + "/" + filePath); + if (StringUtils.isNotEmpty(username) && StringUtils.isNotEmpty(password)) { + url = new URL("ftp://" + username + ":" + URLEncoder.encode(password, StandardCharsets.UTF_8) + "@" + serverAddress + "/" + filePath); + } else { + url = new URL("ftp://" + serverAddress + "/" + filePath); } URLConnection conn = url.openConnection();