From 79b7c8bede6a9ab7ff73ff2f46495869579f9399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=96=E4=B8=8A=E5=8F=AA=E6=9C=8910=E7=A7=8D=E4=BA=BA?= Date: Tue, 31 Jan 2023 07:32:12 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DdecodeUrl=E4=B8=8D=E5=BD=BB?= =?UTF-8?q?=E5=BA=95=E7=9A=84=E9=97=AE=E9=A2=98=20=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=AF=A5=E6=96=B9=E6=B3=95BUG=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 修复前: aHR0cHM6Ly9maWxlLmtla2luZy5jbi9kZW1vL%2BS4reaWhy5wcHR4 -> https://file.keking.cn/demo/%E4%B8%AD%E6%96%87.pptx 修复后: aHR0cHM6Ly9maWxlLmtla2luZy5jbi9kZW1vL%2BS4reaWhy5wcHR4 -> https://file.keking.cn/demo/%E4%B8%AD%E6%96%87.pptx -> https://file.keking.cn/demo/中文.pptx Signed-off-by: 世上只有10种人 --- server/src/main/java/cn/keking/utils/WebUtils.java | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/src/main/java/cn/keking/utils/WebUtils.java b/server/src/main/java/cn/keking/utils/WebUtils.java index bc86b11c..c425376e 100644 --- a/server/src/main/java/cn/keking/utils/WebUtils.java +++ b/server/src/main/java/cn/keking/utils/WebUtils.java @@ -8,6 +8,7 @@ import javax.servlet.ServletRequest; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; +import java.net.URLDecoder; import java.net.URLEncoder; import java.nio.charset.Charset; import java.nio.charset.StandardCharsets; @@ -205,6 +206,13 @@ public class WebUtils { */ public static String decodeUrl(String source) { String url = decodeBase64String(source, StandardCharsets.UTF_8); + + try { + url = URLDecoder.decode(url, StandardCharsets.UTF_8.name()); + } catch (UnsupportedEncodingException e) { + throw new RuntimeException(e); + } + if (! StringUtils.isNotBlank(url)){ return null; }