-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Closed
Labels
Component: WebViewRelated to the WebView component.Related to the WebView component.Platform: AndroidAndroid applications.Android applications.Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.
Description
Environment
React Native Environment Info:
System:
OS: macOS High Sierra 10.13.5
CPU: x64 Intel(R) Core(TM) i7-5557U CPU @ 3.10GHz
Memory: 996.13 MB / 16.00 GB
Shell: 5.5.1 - /usr/local/bin/zsh
Binaries:
Node: 10.5.0 - /usr/local/bin/node
Yarn: 1.7.0 - /usr/local/bin/yarn
npm: 6.1.0 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
SDKs:
iOS SDK:
Platforms: iOS 11.4, macOS 10.13, tvOS 11.4, watchOS 4.3
Android SDK:
Build Tools: 23.0.1, 26.0.3, 27.0.3
API Levels: 19, 23, 26
IDEs:
Xcode: 9.4.1/9F2000 - /usr/bin/xcodebuild
npmPackages:
react-native: ^0.56.0 => 0.56.0
@fanny-pack/react-native: ^1.0.0-beta.1 => 1.0.0-beta.1
@types/react: ^16.4.6 => 16.4.6
@types/react-native: ^0.55.26 => 0.55.28
react: 16.4.1 => 16.4.1
npmGlobalPackages:
create-react-native-app: 1.0.0
react-native-cli: 2.0.1
Description
Any JavaScript passed as the injectedJavaScript
property on the WebView
component on Android isn't properly escaped, and thus can lead to strange SyntaxErrors.
This can be seen here as the raw string is being passed as an javascript:
-uri:
react-native/ReactAndroid/src/main/java/com/facebook/react/views/webview/ReactWebViewManager.java
Lines 328 to 334 in 6e359c4
public void callInjectedJavaScript() { | |
if (getSettings().getJavaScriptEnabled() && | |
injectedJS != null && | |
!TextUtils.isEmpty(injectedJS)) { | |
loadUrl("javascript:(function() {\n" + injectedJS + ";\n})();"); | |
} | |
} |
Reproducible Demo
https://snack.expo.io/rkSxWhNVm
On iOS, three "12" are correctly showing up. On Android, only the first "12" is printed.
albinekb and Dallatron
Metadata
Metadata
Assignees
Labels
Component: WebViewRelated to the WebView component.Related to the WebView component.Platform: AndroidAndroid applications.Android applications.Resolution: LockedThis issue was locked by the bot.This issue was locked by the bot.