Do not use default locale in kotlin generated code (#14668)

Using default locale for non-user visible text transformations is not safe
and can result in bugs, in particular with Turkish locale.

More details in
https://mattryall.net/blog/the-infamous-turkish-locale-bug

Closes #14667
This commit is contained in:
igokoro
2023-03-14 12:47:15 -04:00
committed by GitHub
parent 85ff3de157
commit b172f622b9
21 changed files with 42 additions and 42 deletions

View File

@@ -170,7 +170,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
val contentType = if (headers[ContentType] != null) {
// TODO: support multiple contentType options here.
(headers[ContentType] as String).substringBefore(";").lowercase(Locale.getDefault())
(headers[ContentType] as String).substringBefore(";").lowercase(Locale.US)
} else {
null
}
@@ -189,7 +189,7 @@ open class ApiClient(val baseUrl: String, val client: OkHttpClient = defaultClie
val response = client.newCall(request).execute()
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.getDefault())
val accept = response.header(ContentType)?.substringBefore(";")?.lowercase(Locale.US)
// TODO: handle specific mapping types. e.g. Map<int, Class<?>>
return when {