Skip to content

Commit

Permalink
Maproulette-upload-dag, fix for url encoding issues. (#269)
Browse files Browse the repository at this point in the history
* Maproulette-upload-dag, fix for url encoding issues.

* Maproulette-upload-dag, checkstyle and formatting fixes.

Co-authored-by: sugandhi <[email protected]>
  • Loading branch information
smaheshwaram and sugandhi authored Mar 18, 2020
1 parent 77a9277 commit a3ad581
Showing 1 changed file with 4 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@
import java.io.Serializable;
import java.io.UnsupportedEncodingException;
import java.net.URISyntaxException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Set;

import org.apache.commons.httpclient.URIException;
import org.apache.commons.httpclient.util.URIUtil;
import org.apache.http.HttpStatus;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.entity.ContentType;
Expand Down Expand Up @@ -144,15 +144,8 @@ public long createChallenge(final Project project, final Challenge challenge)
{
final JsonObject challengeJson = challenge.toJson(challenge.getName());
final String type = challengeJson.has(Survey.KEY_ANSWERS) ? KEY_SURVEY : KEY_CHALLENGE;
String encodedChallengeQuery = challenge.getName();
try
{
encodedChallengeQuery = URIUtil.encodeQuery(challenge.getName());
}
catch (final URIException error)
{
logger.info("Unable to encode Challenge name {}.", challenge.getName());
}
final String encodedChallengeQuery = URLEncoder
.encode(challenge.getName(), StandardCharsets.UTF_8).replace("+", "%20");
return create(
String.format("/api/v2/project/%d/challenge/%s", project.getId(),
encodedChallengeQuery),
Expand Down

0 comments on commit a3ad581

Please sign in to comment.