Skip to content

Commit 50285fd

Browse files
author
Joshua
committed
using URLDecoder#decode instead of URLEncoder#encode
1 parent 3008f51 commit 50285fd

2 files changed

Lines changed: 6 additions & 6 deletions

File tree

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
<groupId>de.joshicodes</groupId>
88
<artifactId>webapi</artifactId>
9-
<version>1.3.1c</version>
9+
<version>1.3.1d</version>
1010

1111
<build>
1212
<plugins>

src/main/java/de/joshicodes/webapi/request/RequestData.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
import de.joshicodes.webapi.exceptions.UnknownContentTypeException;
99

1010
import java.io.IOException;
11-
import java.net.URLEncoder;
11+
import java.net.URLDecoder;
1212
import java.nio.charset.StandardCharsets;
1313
import java.util.HashMap;
1414
import java.util.List;
@@ -78,7 +78,7 @@ public HashMap<String, String> getPostParameters() throws MissingPostDataExcepti
7878
if (param.contains("=")) {
7979
String[] split = param.split("=");
8080
if (split.length == 2)
81-
parameters.put(split[0], URLEncoder.encode(split[1], StandardCharsets.UTF_8));
81+
parameters.put(split[0], URLDecoder.decode(split[1], StandardCharsets.UTF_8));
8282
else if (split.length == 1)
8383
parameters.put(split[0], null);
8484
} else {
@@ -116,7 +116,7 @@ public HashMap<String, String> getParameters() {
116116
if (param.contains("=")) {
117117
String[] split = param.split("=");
118118
if (split.length == 2)
119-
parameters.put(split[0], URLEncoder.encode(split[1], StandardCharsets.UTF_8));
119+
parameters.put(split[0], URLDecoder.decode(split[1], StandardCharsets.UTF_8));
120120
else if (split.length == 1)
121121
parameters.put(split[0], null);
122122
} else {
@@ -153,7 +153,7 @@ public String getParameter(String key) {
153153
try {
154154
String param = getPostParameters().get(key);
155155
if(param != null) {
156-
return URLEncoder.encode(param, StandardCharsets.UTF_8);
156+
return URLDecoder.decode(param, StandardCharsets.UTF_8);
157157
}
158158
return null;
159159
} catch (MissingPostDataException | UnknownContentTypeException e) {
@@ -183,7 +183,7 @@ public String[] getUriParts() {
183183
* @return the value of the parameter, always a string
184184
*/
185185
public String getParameter(String key, String def) {
186-
return URLEncoder.encode(getParameters().getOrDefault(key, def), StandardCharsets.UTF_8);
186+
return URLDecoder.decode(getParameters().getOrDefault(key, def), StandardCharsets.UTF_8);
187187
}
188188

189189
public String getPath() {

0 commit comments

Comments
 (0)