From ce1c0bab452482621d102ab3154df10870a436d7 Mon Sep 17 00:00:00 2001 From: Looly Date: Tue, 18 Apr 2023 16:35:29 +0800 Subject: [PATCH] fix decoder bug --- .../src/main/java/cn/hutool/core/net/URLDecoder.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hutool-core/src/main/java/cn/hutool/core/net/URLDecoder.java b/hutool-core/src/main/java/cn/hutool/core/net/URLDecoder.java index 088c4ad6a..4e399e369 100644 --- a/hutool-core/src/main/java/cn/hutool/core/net/URLDecoder.java +++ b/hutool-core/src/main/java/cn/hutool/core/net/URLDecoder.java @@ -88,11 +88,6 @@ public class URLDecoder implements Serializable { char c; for (int i = 0; i < length; i++) { c = str.charAt(i); - if('+' == c){ - result.append(isPlusToSpace ? CharUtil.SPACE : c); - begin++; - continue; - } if(ESCAPE_CHAR == c || CharUtil.isHexChar(c)){ continue; } @@ -103,6 +98,11 @@ public class URLDecoder implements Serializable { result.append(decodeSub(str, begin, i, charset, isPlusToSpace)); } + // 非Hex字符,忽略本字符 + if('+' == c && isPlusToSpace){ + c = CharUtil.SPACE; + } + // 非Hex字符,忽略本字符 result.append(c); begin = i + 1;