You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using React Native's FormData on Android to upload a file, things in the header Content-Disposition, such as the filename will get stripped, if they contain non-ASCII characters such as Chinese.
For example, uploading a file with the name "test测试test.jpg":
Description
When using React Native's
FormData
on Android to upload a file, things in the headerContent-Disposition
, such as the filename will get stripped, if they contain non-ASCII characters such as Chinese.For example, uploading a file with the name "test测试test.jpg":
The actual HTTP headers sent will only include
filename=testtest.jpg
with测试
stripped.As I investigate, I find lines of code that should be responsible https://github.com/facebook/react-native/blob/ebc89bfb788102fbcf3eab070c5603d351620e23/ReactAndroid/src/main/java/com/facebook/react/modules/network/HeaderUtil.java.
These methods are to weaken okhttp's too strict rules on headers, but also bring this unwanted behavior.
FYI, okhttp has supported non-ASCII headers from square/okhttp#4296.
These two stripping methods may need to be looked into and synced with the upstream to reflect okhttp's changes.
This change was brought by #21231 in response to the issue square/okhttp#2802. The issue has been discussed in another one square/okhttp#3876, which was fixed by square/okhttp#4296.
React Native version:
Steps To Reproduce
Expected Results
Non-ASCII strings in headers should not be stripped, especially not for filenames.
Snack, code example, screenshot, or link to a repository:
Shown above.
The text was updated successfully, but these errors were encountered: