From e5788016cf9792f2f4561fd78ea251bb8bda25e9 Mon Sep 17 00:00:00 2001 From: Marcel Hibbe Date: Thu, 26 Oct 2023 13:25:33 +0200 Subject: [PATCH] Use UTF_8 for basic authorization Signed-off-by: Marcel Hibbe --- .../com/nextcloud/talk/dagger/modules/RestModule.java | 10 +++++++--- .../main/java/com/nextcloud/talk/utils/ApiUtils.java | 3 ++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/nextcloud/talk/dagger/modules/RestModule.java b/app/src/main/java/com/nextcloud/talk/dagger/modules/RestModule.java index 996d46d39c..795dd12820 100644 --- a/app/src/main/java/com/nextcloud/talk/dagger/modules/RestModule.java +++ b/app/src/main/java/com/nextcloud/talk/dagger/modules/RestModule.java @@ -40,6 +40,7 @@ import java.net.CookieManager; import java.net.InetSocketAddress; import java.net.Proxy; +import java.nio.charset.StandardCharsets; import java.security.KeyStore; import java.security.KeyStoreException; import java.security.NoSuchAlgorithmException; @@ -209,9 +210,12 @@ OkHttpClient provideHttpClient(Proxy proxy, AppPreferences appPreferences, if (appPreferences.getProxyCredentials() && !TextUtils.isEmpty(appPreferences.getProxyUsername()) && !TextUtils.isEmpty(appPreferences.getProxyPassword())) { - httpClient.proxyAuthenticator(new HttpAuthenticator(Credentials.basic( - appPreferences.getProxyUsername(), - appPreferences.getProxyPassword()), "Proxy-Authorization")); + httpClient.proxyAuthenticator(new HttpAuthenticator( + Credentials.basic( + appPreferences.getProxyUsername(), + appPreferences.getProxyPassword(), + StandardCharsets.UTF_8), + "Proxy-Authorization")); } } diff --git a/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java b/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java index 4b0ec13d9d..eb9e5f4b89 100644 --- a/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java +++ b/app/src/main/java/com/nextcloud/talk/utils/ApiUtils.java @@ -34,6 +34,7 @@ import com.nextcloud.talk.models.RetrofitBucket; import com.nextcloud.talk.utils.database.user.CapabilitiesUtilNew; +import java.nio.charset.StandardCharsets; import java.util.HashMap; import java.util.Map; @@ -399,7 +400,7 @@ public static String getCredentials(String username, String token) { if (TextUtils.isEmpty(username) && TextUtils.isEmpty(token)) { return null; } - return Credentials.basic(username, token); + return Credentials.basic(username, token, StandardCharsets.UTF_8); } public static String getUrlNextcloudPush(String baseUrl) {