From c2a729d072569d955ae1fe068f6a1d8aa9655923 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jc=20Mi=C3=B1arro?= Date: Tue, 15 Oct 2024 14:31:09 +0200 Subject: [PATCH] Sanitize User Agen Header --- .../android/core/internal/module/ConnectionModule.kt | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/internal/module/ConnectionModule.kt b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/internal/module/ConnectionModule.kt index 2b5b85b0e5..2cc0bd32e4 100644 --- a/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/internal/module/ConnectionModule.kt +++ b/stream-video-android-core/src/main/kotlin/io/getstream/video/android/core/internal/module/ConnectionModule.kt @@ -41,6 +41,7 @@ import retrofit2.converter.moshi.MoshiConverterFactory import retrofit2.converter.scalars.ScalarsConverterFactory import retrofit2.converter.wire.WireConverterFactory import java.io.IOException +import java.text.Normalizer import java.util.concurrent.TimeUnit /** @@ -338,8 +339,14 @@ internal class HeadersInterceptor( } }.getOrNull() ?: "StandAloneInstall" - return "$appName / $versionName($versionCode); $installerName; ($manufacturer; " + - "$model; SDK $version; Android $versionRelease)" + return ("$appName / $versionName($versionCode); $installerName; ($manufacturer; " + + "$model; SDK $version; Android $versionRelease)") + .sanitize() } } + + private fun String.sanitize(): String { + return Normalizer.normalize(this, Normalizer.Form.NFD) + .replace("[^\\p{ASCII}]".toRegex(), "") + } }