injected javascript comments now work on android#12321
Closed
mishuagopian wants to merge 1 commit intofacebook:masterfrom
mishuagopian:comment-on-android-webview-fix
Closed
injected javascript comments now work on android#12321mishuagopian wants to merge 1 commit intofacebook:masterfrom mishuagopian:comment-on-android-webview-fix
mishuagopian wants to merge 1 commit intofacebook:masterfrom
mishuagopian:comment-on-android-webview-fix
Conversation
Contributor
|
Does this means it will only work properly with comments on kitkat+? |
Contributor
|
@mishuagopian I tried to find reviewers for this pull request and wanted to ping them to take another look. However, based on the blame information for the files in this pull request I couldn't find any reviewers. This sometimes happens when the files in the pull request are new or don't exist on master anymore. Is this pull request still relevant? If yes could you please rebase? In case you know who has context on this code feel free to mention them in a comment (one person is fine). Thanks for reading and hope you will continue contributing to the project. |
shergin
suggested changes
Aug 29, 2017
| injectedJS != null && | ||
| !TextUtils.isEmpty(injectedJS)) { | ||
| loadUrl("javascript:(function() {\n" + injectedJS + ";\n})();"); | ||
| String code = "(function() {\n" + injectedJS + ";\n})();"; |
Contributor
There was a problem hiding this comment.
Why do we need this wrapping here?
This was referenced Jun 7, 2018
kelset
pushed a commit
that referenced
this pull request
Aug 13, 2018
Summary: These changes will fix executing javascript with any special characters, by making use of the `evaluateJavascript` function on Android 4.4+, and by properly escaping the URI on Android <4.4. Fixes #19611 • Fixes #20365 • Fixes #9749 • Closes #19655 • Closes #12321 This PR supersedes #19655 by patching the same problem in all the places, and fixing it for Android <4.4 as well. Pull Request resolved: #20366 Differential Revision: D9242968 Pulled By: hramos fbshipit-source-id: f2e1abc786ba333dbd8aaa8922e716fd99ec26e0
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
When injecting a script to a WebView component via injectedJavaScript prop, if the script contains any comment then it won't work on android (issue: #9749).
Test plan
Create a
WebViewin which we inject a script with a simple comment in it.Code to reproduce
Expected Results
Text on html
h1element ("Hello!") should be replaced with "Bye!" text.Actual Results
Text on
h1html element changes on iOS but not on Android. Removing the comment on the js script will fix this issue.