Skip to content

Commit

Permalink
Sanitize User Agen Header
Browse files Browse the repository at this point in the history
  • Loading branch information
JcMinarro committed Oct 15, 2024
1 parent 0cf9aaf commit f0787f5
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

/**
Expand Down Expand Up @@ -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(), "")
}
}

0 comments on commit f0787f5

Please sign in to comment.