In webview I will be loading static html file with css.
webView.loadUrl("file:///android_asset/customhtml.html
In that html I have also set encoding in meta tag as <meta http-equiv="content-type" content="text/html; charset=utf-8"/>
After this file is loaded I will be setting content as
webView.loadUrl("javascript:setContent(" + JSONObject.quote(content)+")");
here is javascript
`function setContent(contentToSet)
{
setBaseURL();
var mailContentElement = document.getElementById('mailcontentid');
mailContentElement.innerHTML = ""
handleContentinHTML($('mailcontentid'),contentToSet);
androidResponse(true); //method to call android js interface
}
function handleContentinHTML (contentEl, value)
{
contentEl.innerHTML = value;
}`
Problem: When setting contentlike filename=0000%3Cimg%20src%3da%20onerror%3dalert(test)%3Eb4911111
this gets converted to html image tag and alert message is shown. This content is not displayed exactly as in text form.
some tests I tried:
1 - settinge encoding in webview settings settings.setDefaultTextEncodingName("utf-8");
2 - convert the html file to string and load as myWebView.loadDataWithBaseURL(null, convertfiletohtmlString, "text/html", "utf-8", null);
and setting the content using javascript.
3 - using escape(contentToSet)
in javascript ;
Nothing seems to work. Please help me an post your suggestions.