URLEncode shortCode paths

This commit is contained in:
Ravi Khadiwala 2024-09-23 13:55:15 -05:00 committed by ravi-signal
parent bf0f553ced
commit ba12d39121
1 changed files with 3 additions and 1 deletions

View File

@ -9,9 +9,11 @@ import io.micrometer.core.instrument.Metrics;
import org.apache.http.HttpStatus;
import java.io.IOException;
import java.net.URI;
import java.net.URLEncoder;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
import java.nio.charset.StandardCharsets;
import java.util.Optional;
import static org.whispersystems.textsecuregcm.metrics.MetricsUtil.name;
@ -28,7 +30,7 @@ public class ShortCodeExpander {
}
public Optional<String> retrieve(final String shortCode) throws IOException {
final URI uri = shortenerHost.resolve(shortCode);
final URI uri = shortenerHost.resolve(URLEncoder.encode(shortCode, StandardCharsets.UTF_8));
final HttpRequest request = HttpRequest.newBuilder().uri(uri).GET().build();
try {