fix decode

This commit is contained in:
Looly 2023-04-18 12:24:21 +08:00
parent f66b5fe55e
commit 55ca246d3c
2 changed files with 11 additions and 0 deletions

View File

@ -134,6 +134,11 @@ public class URLDecoder implements Serializable {
char c; char c;
for (int i = 0; i < length; i++) { for (int i = 0; i < length; i++) {
c = str.charAt(i); c = str.charAt(i);
if(CharUtil.PLUS == c){
result.append(isPlusToSpace ? CharUtil.SPACE : c);
begin++;
continue;
}
if(ESCAPE_CHAR == c || CharUtil.isHexChar(c)){ if(ESCAPE_CHAR == c || CharUtil.isHexChar(c)){
continue; continue;
} }

View File

@ -16,6 +16,12 @@ public class UrlDecoderTest {
Assertions.assertEquals("+", URLDecoder.decodeForPath("+", CharsetUtil.UTF_8)); Assertions.assertEquals("+", URLDecoder.decodeForPath("+", CharsetUtil.UTF_8));
} }
@Test
public void decodePlusTest() {
final String decode = URLDecoder.decode("+", CharsetUtil.UTF_8);
Assertions.assertEquals(" ", decode);
}
@Test @Test
void issue3063Test() throws UnsupportedEncodingException { void issue3063Test() throws UnsupportedEncodingException {
// https://github.com/dromara/hutool/issues/3063 // https://github.com/dromara/hutool/issues/3063