Commit 4a5df0d
committed
webview: Encode input messages in base64
Fixes #2505 #2538 #2558
When using `postMessage` to communicate with the WebView, depending
on the content of the message we send, an exception might be thrown.
A minimal but reliable way to reproduce the issue is to send
the string `'%22'`. Other character combinations might also cause issues.
Messages are sent to the WebView in different ways for iOS/Android.
This explains why the issue this is fixing is Android-specific.
In iOS, a custom navigation scheme is used to pass the data into
the webview (the RCTJSNavigationScheme constant one can grep for)
More interesting source code reading on that can be done if one
looks at `webViewDidFinishLoad` in `RTCWebView.m`.
The Android messaging happens in `receiveCommand` in `ReactWebViewManager.java`
It is passed by navigating to a URL of the type `javascript:(.....)`
which is a standard way of injecting JavaScript into webpages.
The issue comes from the fact that `loadUrl` since Android 4.4 does
an URL decode on the string passed to it:
https://developer.android.com/reference/android/webkit/WebView#loadUrl(java.lang.String)
`evaluateJavascript` does not:
https://developer.android.com/reference/android/webkit/WebView.html#evaluateJavascript(java.lang.String,%20android.webkit.ValueCallback%3Cjava.lang.String%3E)1 parent 3edd349 commit 4a5df0d
3 files changed
+6
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| 13 | + | |
13 | 14 | | |
14 | 15 | | |
15 | 16 | | |
| |||
29 | 30 | | |
30 | 31 | | |
31 | 32 | | |
32 | | - | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
241 | 241 | | |
242 | 242 | | |
243 | 243 | | |
244 | | - | |
| 244 | + | |
| 245 | + | |
245 | 246 | | |
246 | 247 | | |
247 | 248 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
261 | 261 | | |
262 | 262 | | |
263 | 263 | | |
264 | | - | |
| 264 | + | |
| 265 | + | |
265 | 266 | | |
266 | 267 | | |
267 | 268 | | |
| |||
0 commit comments