How to address “Remediation for JavaScript Interface Injection Vulnerability”?

后端 未结 1 1029
孤街浪徒
孤街浪徒 2021-01-15 04:48

Google has asked me to address https://support.google.com/faqs/answer/9095419 in my Android app, which basically means not to use the JavaScript injection mechanism for a we

1条回答
  •  南笙
    南笙 (楼主)
    2021-01-15 05:06

    I have not found a way to use file:// URLs with assets in a way that satisfies Google code checker. While this would solve the issue, I'm still not clear how one might need to code it.

    What I ended up doing -which solves my immediate problem- is to call a JavaScript method via the WebView.evaluateJavascript method. When called from within WebViewClient.onPageFinished the page has finished loading, so all elements are accessible. While not important for my case, this method can also return a value to the Java code. So while it's not a general replacement for a JavascriptInterface, it addresses some of its uses cases.

    0 讨论(0)
提交回复
热议问题