question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

okhttp3 3.12.x parse Part BUG

See original GitHub issue

Good 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:closed
  • Created 5 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

3reactions
valepakhcommented, Feb 15, 2019

Is it possible to backport this to 3.12.x?

0reactions
lognaturelcommented, Aug 3, 2019

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). 🎉

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found