mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
fix decode
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package cn.hutool.core.net;
|
||||
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.core.util.CharUtil;
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -87,6 +88,11 @@ 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;
|
||||
}
|
||||
|
@@ -14,6 +14,12 @@ public class UrlDecoderTest {
|
||||
Assert.assertEquals("+", URLDecoder.decodeForPath("+", CharsetUtil.CHARSET_UTF_8));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void decodePlusTest() {
|
||||
final String decode = URLDecoder.decode("+", CharsetUtil.CHARSET_UTF_8);
|
||||
Assert.assertEquals(" ", decode);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void issue3063Test() throws UnsupportedEncodingException {
|
||||
// https://github.com/dromara/hutool/issues/3063
|
||||
|
Reference in New Issue
Block a user