okhttp3 3.12.x parse Part BUG
See original GitHub issueGood bug reports include a failing test! Writing a test helps you to isolate and describe the problem, and it helps us to fix it fast. Bug reports without a failing test or reproduction steps are likely to be closed.
Here’s an example test to get you started. https://gist.github.com/swankjesse/981fcae102f513eb13ed
Version :
3.12.x
Error description :
When the MultipartBody.Part.createFormData(String name, @Nullable String filename, RequestBody body)
method is called, if the file name contains Chinese, an IllegalArgumentException will be thrown to locate the calling chain:
MultipartBody.Part.createFormData(String name, @Nullable String filename, RequestBody body)
Headers.of(String... namesAndValues)
Headers.checkValue(String value, String name)
The final code is as follows:
static void checkValue(String value, String name) {
if (value == null) throw new NullPointerException("value for name " + name + " == null");
for (int i = 0, length = value.length(); i < length; i++) {
char c = value.charAt(i);
if ((c <= '\u001f' && c != '\t') || c >= '\u007f') {
throw new IllegalArgumentException(Util.format(
"Unexpected char %#04x at %d in %s value: %s", (int) c, i, name, value));
}
}
}
As shown above, this code does not handle Chinese correctly.
Issue Analytics
- State:
- Created 5 years ago
- Comments:8 (3 by maintainers)
Top Results From Across the Web
3.x Change Log - OkHttp
We had a bug where two calls that failed at the same time could cause OkHttp to crash with a NoSuchElementException instead of...
Read more >Using okhttp 3.12.x from java 7? - Stack Overflow
Answering my own question. After some feedback from the okhttp devs on an issue created for this at:.
Read more >A complete guide to OkHttp - LogRocket Blog
In this guide, you can learn the basics of OkHttp and how to build an imaginary to-do list application for Android with it....
Read more >void okhttp3.internal.internal.initializeinstancefortests()
I just upgraded Android Studio 4.1 and got all the tests related to mock webserver failed in IDE but not in terminal. It...
Read more >OkHttpClient (OkHttp 3.12.3 API) - javadoc.io
If your client has a cache, call close() . Note that it is an error to create calls against a cache that is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Is it possible to backport this to 3.12.x?
Thanks so much for this backport, @valepakh, and for the merge, @swankjesse. You’re helping folks collect data in challenging environments (and languages with Unicode characters). 🎉