Provide URL encoded placeholders in notification template for 3PID data

This commit is contained in:
Max Dor
2019-05-18 02:20:13 +02:00
parent f16f184253
commit 27b2976e42
4 changed files with 75 additions and 20 deletions

View File

@@ -25,12 +25,22 @@ import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.ContentType;
import org.apache.http.entity.StringEntity;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.nio.charset.StandardCharsets;
public class RestClientUtils {
private static Gson gson = GsonUtil.build();
public static String urlEncode(String value) {
try {
return URLEncoder.encode(value, StandardCharsets.UTF_8.name());
} catch (UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
}
public static HttpPost post(String url, String body) {
StringEntity entity = new StringEntity(body, StandardCharsets.UTF_8);
entity.setContentType(ContentType.APPLICATION_JSON.toString());