Skip to content

Commit a3ad581

Browse files
smaheshwaramsugandhi
andauthored
Maproulette-upload-dag, fix for url encoding issues. (#269)
* Maproulette-upload-dag, fix for url encoding issues. * Maproulette-upload-dag, checkstyle and formatting fixes. Co-authored-by: sugandhi <[email protected]>
1 parent 77a9277 commit a3ad581

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

src/main/java/org/openstreetmap/atlas/checks/maproulette/MapRouletteConnection.java

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
import java.io.Serializable;
44
import java.io.UnsupportedEncodingException;
55
import java.net.URISyntaxException;
6+
import java.net.URLEncoder;
7+
import java.nio.charset.StandardCharsets;
68
import java.util.ArrayList;
79
import java.util.Collections;
810
import java.util.List;
911
import java.util.Set;
1012

11-
import org.apache.commons.httpclient.URIException;
12-
import org.apache.commons.httpclient.util.URIUtil;
1313
import org.apache.http.HttpStatus;
1414
import org.apache.http.client.utils.URIBuilder;
1515
import org.apache.http.entity.ContentType;
@@ -144,15 +144,8 @@ public long createChallenge(final Project project, final Challenge challenge)
144144
{
145145
final JsonObject challengeJson = challenge.toJson(challenge.getName());
146146
final String type = challengeJson.has(Survey.KEY_ANSWERS) ? KEY_SURVEY : KEY_CHALLENGE;
147-
String encodedChallengeQuery = challenge.getName();
148-
try
149-
{
150-
encodedChallengeQuery = URIUtil.encodeQuery(challenge.getName());
151-
}
152-
catch (final URIException error)
153-
{
154-
logger.info("Unable to encode Challenge name {}.", challenge.getName());
155-
}
147+
final String encodedChallengeQuery = URLEncoder
148+
.encode(challenge.getName(), StandardCharsets.UTF_8).replace("+", "%20");
156149
return create(
157150
String.format("/api/v2/project/%d/challenge/%s", project.getId(),
158151
encodedChallengeQuery),

0 commit comments

Comments
 (0)