Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This ensures no illegal cookies are send to okhttp
When a website in a ReactNative WebView sets a cookie with an illegal character, this cookie will automatically be added to any request to the same domain. This happens through: BridgeInterceptor.java (l.84) ReactCookieJarContainer.java (l.44) JavaNetCookieJar.java (l.59) ForwardingCookieHandler.java (l.57) ForwardingCookieHandler.java (l.168) CookieManager.java (l.39) The BridgeInterceptor.java then tries to set a Cookie header, which validates both keys and values, and then crashes. okhttp3.6.0 Headers.java (l.320) I would have expected that the IllegalArgumentException would have been caught by JavaMethodRapper.java (l.376), because that's where the NetworkingModule is triggered to build the okhttp request, but my guess is that this is not caught, because IllegalArgumentException is not an IOException. Interceptor can only throw IOExceptions.
- Loading branch information
d0ea19f
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Catching the IllegalArgumentException in okhttp and transforming it to an IOException doesn't work either. The issue is that JavaMethodRapper / NetworkingModule only adds a call to a queue.
Sometime later the call is triggered asynchronous by okhttp, and only exceptions in the response are being forwarded.
See: square/okhttp#3774