User agent contains non-ASCII chars in some locales and causes IllegalArgumentException



  • DAVdroid sets its own user agent for requests, which contains the build date. The date is formatted with SimpleDateFormat("yyyy/MM/dd", Locale.getDefault()). The problem is that in some locales, especially fa-IR, this format generates strings like ۲۰۱۸/۰۵/۰۵. As a result, the final user agent contains non-ASCII characters which causes IllegalArgumentException in underlying okhttp library.

    Sample error log can be found here. The related issue in okhttp is Non-ASCII Header Encoding Issues.

    I suggest using non-localized date format in user agent to fix this problem.


  • developer

    Hello,

    Thanks for the hint 🙂 I didn't have in mind that numbers (year, month, day) could have non-ASCII representations. Should be fixed with 9aa58d17.

    I have sent an APK over email, please tell me whether it solves your problem.



  • Thanks for the quick response. I haven't received the apk (probably due to Gmail), but built and tested the last version of code and the problem is fixed.