Skip to content

Commit

Permalink
CSCEXAM-1384 Enrolment permission check: change handling of params
Browse files Browse the repository at this point in the history
- query params must not be url encoded before passing to ws client
  because it re-encodes them while executing requests
  • Loading branch information
lupari committed Nov 7, 2024
1 parent 8b8a872 commit 30d8a51
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions app/impl/ExternalCourseHandlerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,8 @@
import io.ebean.DB;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URL;
import java.net.URLEncoder;
import java.net.*;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.text.DateFormat;
import java.text.ParseException;
Expand Down Expand Up @@ -144,7 +142,8 @@ public CompletionStage<Collection<String>> getPermittedCourses(User user) throws
URL url = parseUrl(user);
WSRequest request = wsClient.url(url.toString().split("\\?")[0]);
if (url.getQuery() != null) {
request = request.setQueryString(url.getQuery());
// Ws Client does encode the query so we need to decode it back first, bit dumb though
request = request.setQueryString(URLDecoder.decode(url.getQuery(), Charset.defaultCharset()));
}
if (configReader.isApiKeyUsed()) {
request = request.addHeader(configReader.getApiKeyName(), configReader.getApiKeyValue());
Expand Down

0 comments on commit 30d8a51

Please sign in to comment.