Skip to content

The Unified and Autonomous Development Platform

Add UTF-8 support for webhooks

Ilya5b962535376d
diff --git a/server-core/src/main/java/io/onedev/server/notification/WebHookManager.java b/server-core/src/main/java/io/onedev/server/notification/WebHookManager.java
index 37cf251735..9bdd5d4bdb 100644
--- a/server-core/src/main/java/io/onedev/server/notification/WebHookManager.java
+++ b/server-core/src/main/java/io/onedev/server/notification/WebHookManager.java
@@ -1,6 +1,7 @@
package io.onedev.server.notification;
import java.io.IOException;
+import java.nio.charset.StandardCharsets;
import java.util.concurrent.ExecutorService;
import javax.inject.Inject;
@@ -66,10 +67,11 @@ public class WebHookManager {
try {
HttpPost httpPost = new HttpPost(webHook.getPostUrl());
- StringEntity entity = new StringEntity(jsonOfEvent);
+ StringEntity entity = new StringEntity(jsonOfEvent, StandardCharsets.UTF_8.name());
httpPost.setEntity(entity);
httpPost.setHeader(HttpHeaders.ACCEPT, MediaType.APPLICATION_JSON);
httpPost.setHeader(HttpHeaders.CONTENT_TYPE, MediaType.APPLICATION_JSON);
+ httpPost.setHeader(HttpHeaders.ACCEPT_CHARSET, StandardCharsets.UTF_8.name());
httpPost.setHeader(SIGNATURE_HEAD, webHook.getSecret());
CloseableHttpResponse response = client.execute(httpPost);