You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And a Javascript file which just sets the src of the WebView to an HTML string:
var webViewModule = require('ui/web-view');
var gridLayout = require('ui/layouts/grid-layout');
function pageLoaded(args) {
page = args.object;
var wv = new webViewModule.WebView();
var container = page.getViewById('container');
gridLayout.GridLayout.setColumn(wv, 0);
gridLayout.GridLayout.setRow(wv, 0);
container.addChild(wv);
wv.src = '<!DOCTYPE html>' +
'<html lang="en">' +
'<head>' +
'<meta charset="utf-8">' +
'<meta http-equiv="content-type" content="text/html; charset=UTF-8">' +
'<meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, user-scalable=no, user-scalable=0" />' +
'<title>Test Page</title>' +
'</head>' +
'<body>' +
'<h1>Hi there</h1>' +
'<h2>Here are some Swedish characters: ÅÄÖ</h2>' +
'</body>' +
'</html>';
}
exports.pageLoaded = pageLoaded;
The above works perfectly on all my devices. However, I've got a bug report from a user running Android 4.3/API 18 (on a Samsung Galaxy S3). On her device, the WebView displays the HTML code:
After a long time debugging, it looks like her 4.3 device doesn't understand the MIME type text/html; charset=utf-8 set in web-view.android.ts, and renders it as text/plain instead.
When removing the ; charset=utf-8 part on both places in the file linked above, it worked and rendered as it should.
However. The ; charset=utf-8 part was added (by me in this PR) because internet suggested it was needed for UTF-8 characters to work on some API versions. (E.g. StackOverflow).
As I don't have a battery of devices/tests I don't feel comfortable sending a PR removing this.
Imho what needs to be done is:
Remove the ; charset=utf-8
Run tests to see that UTF-8 characters (such as ÅÄÖ) are still displayed on all devices from API 17 up to todays number
when given a HTML string.
when given a the URI to a local HTML file inside the {N} app
Summary:
Resolves#11753 and #9835.
Android versions 4.1-4.3 don't understand the MIME type `text/html; charset=utf-8` and default to `text/plain` instead, rendering the content as an unparsed HTML string. Since the encoding is already set and passed separately, removing it from the MIME type has no negative effects.
The same fix has already been discussed, successfully tested and incorporated in NativeScript/NativeScript#1038.
Closes#13789
Differential Revision: D5971910
Pulled By: shergin
fbshipit-source-id: 07795bdf0f13ddb1e8eec779d1cad59244f3687e
It seems like older versions of Android doesn't render the WebView correctly when given a WebView with a
src
set to a HTML string.Easiest describe with an example, given a simple page page like this:
And a Javascript file which just sets the
src
of the WebView to an HTML string:The above works perfectly on all my devices. However, I've got a bug report from a user running Android 4.3/API 18 (on a Samsung Galaxy S3). On her device, the WebView displays the HTML code:
After a long time debugging, it looks like her 4.3 device doesn't understand the MIME type
text/html; charset=utf-8
set in web-view.android.ts, and renders it astext/plain
instead.When removing the
; charset=utf-8
part on both places in the file linked above, it worked and rendered as it should.However. The
; charset=utf-8
part was added (by me in this PR) because internet suggested it was needed for UTF-8 characters to work on some API versions. (E.g. StackOverflow).As I don't have a battery of devices/tests I don't feel comfortable sending a PR removing this.
Imho what needs to be done is:
; charset=utf-8
The text was updated successfully, but these errors were encountered: