Skip to content

Commit

Permalink
fix: App crash when app name contains contain non-ASCII characters (#562
Browse files Browse the repository at this point in the history
)

- We include the application name in the User-Agent request header to
identify the app usage. If the app name includes special characters, it
leads to a crash because the header value should not contain non-ASCII
values. square/okhttp#891
- In this commit, we have passed the package name to the User-Agent
instead of the App name because the package name is also unique.
  • Loading branch information
PruthiviRaj27 committed Aug 14, 2023
1 parent 8dee289 commit 0b988be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions core/src/main/java/in/testpress/util/UserAgentProvider.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*
* Example
*
* testpress/1.1.2 (Dalvik; Android 9; Xiaomi POCO F1 Build/PKQ1.180729.001) okhttp
* in.testpress.samples/1.1.2 (Dalvik; Android 9; Xiaomi POCO F1 Build/PKQ1.180729.001) okhttp
*
*/
public class UserAgentProvider {
Expand All @@ -34,7 +34,7 @@ public static String get(Context context) {
e.printStackTrace();
}
userAgent = String.format("%s/%s (Dalvik; Android %s; %s %s Build/%s) okhttp",
context.getApplicationInfo().loadLabel(context.getPackageManager()),
context.getApplicationInfo().packageName,
appVersion,
Build.VERSION.RELEASE,
Build.MANUFACTURER,
Expand Down

0 comments on commit 0b988be

Please sign in to comment.