Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1bb1a911 authored by Leon Scroggins's avatar Leon Scroggins
Browse files

If failUrl(now historyUrl) is null, use "about:blank" instead of "".

This prevents a crash that is caused by calling
WebView.loadDataWithBaseUrl with a null failUrl (which I have renamed
to historyUrl).  Also update the docs to be more accurate.

Fixes the general case of bug 2522457

Change-Id: I832351ce1e0016b00e924a2f9b0097ae15fba34a
parent 7f49b9e4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -195481,7 +195481,7 @@
</parameter>
<parameter name="encoding" type="java.lang.String">
</parameter>
<parameter name="failUrl" type="java.lang.String">
<parameter name="historyUrl" type="java.lang.String">
</parameter>
</method>
<method name="loadUrl"
+7 −9
Original line number Diff line number Diff line
@@ -213,21 +213,19 @@ class BrowserFrame extends Handler {

    /**
     * Load the content as if it was loaded by the provided base URL. The
     * failUrl is used as the history entry for the load data. If null or
     * an empty string is passed for the failUrl, then no history entry is
     * created.
     * historyUrl is used as the history entry for the load data.
     * 
     * @param baseUrl Base URL used to resolve relative paths in the content
     * @param data Content to render in the browser
     * @param mimeType Mimetype of the data being passed in
     * @param encoding Character set encoding of the provided data.
     * @param failUrl URL to use if the content fails to load or null.
     * @param historyUrl URL to use as the history entry.
     */
    public void loadData(String baseUrl, String data, String mimeType,
            String encoding, String failUrl) {
            String encoding, String historyUrl) {
        mLoadInitFromJava = true;
        if (failUrl == null) {
            failUrl = "";
        if (historyUrl == null || historyUrl.length() == 0) {
            historyUrl = "about:blank";
        }
        if (data == null) {
            data = "";
@@ -241,7 +239,7 @@ class BrowserFrame extends Handler {
        if (mimeType == null || mimeType.length() == 0) {
            mimeType = "text/html";
        }
        nativeLoadData(baseUrl, data, mimeType, encoding, failUrl);
        nativeLoadData(baseUrl, data, mimeType, encoding, historyUrl);
        mLoadInitFromJava = false;
    }

@@ -916,7 +914,7 @@ class BrowserFrame extends Handler {
    private native void nativePostUrl(String url, byte[] postData);

    private native void nativeLoadData(String baseUrl, String data,
            String mimeType, String encoding, String failUrl);
            String mimeType, String encoding, String historyUrl);

    /**
     * Stop loading the current page.
+5 −7
Original line number Diff line number Diff line
@@ -1483,10 +1483,8 @@ public class WebView extends AbsoluteLayout
    /**
     * Load the given data into the WebView, use the provided URL as the base
     * URL for the content. The base URL is the URL that represents the page
     * that is loaded through this interface. As such, it is used for the
     * history entry and to resolve any relative URLs. The failUrl is used if
     * browser fails to load the data provided. If it is empty or null, and the
     * load fails, then no history entry is created.
     * that is loaded through this interface. As such, it is used to resolve any
     * relative URLs. The historyUrl is used for the history entry.
     * <p>
     * Note for post 1.0. Due to the change in the WebKit, the access to asset
     * files through "file:///android_asset/" for the sub resources is more
@@ -1501,10 +1499,10 @@ public class WebView extends AbsoluteLayout
     * @param mimeType The MIMEType of the data. i.e. text/html. If null,
     *            defaults to "text/html"
     * @param encoding The encoding of the data. i.e. utf-8, us-ascii
     * @param failUrl URL to use if the content fails to load or null.
     * @param historyUrl URL to use as the history entry.  Can be null.
     */
    public void loadDataWithBaseURL(String baseUrl, String data,
            String mimeType, String encoding, String failUrl) {
            String mimeType, String encoding, String historyUrl) {

        if (baseUrl != null && baseUrl.toLowerCase().startsWith("data:")) {
            loadData(data, mimeType, encoding);
@@ -1516,7 +1514,7 @@ public class WebView extends AbsoluteLayout
        arg.mData = data;
        arg.mMimeType = mimeType;
        arg.mEncoding = encoding;
        arg.mFailUrl = failUrl;
        arg.mHistoryUrl = historyUrl;
        mWebViewCore.sendMessage(EventHub.LOAD_DATA, arg);
        clearTextEntry(false);
    }
+2 −2
Original line number Diff line number Diff line
@@ -627,7 +627,7 @@ final class WebViewCore {
        String mData;
        String mMimeType;
        String mEncoding;
        String mFailUrl;
        String mHistoryUrl;
    }

    static class CursorData {
@@ -981,7 +981,7 @@ final class WebViewCore {
                                    loadParams.mData,
                                    loadParams.mMimeType,
                                    loadParams.mEncoding,
                                    loadParams.mFailUrl);
                                    loadParams.mHistoryUrl);
                            break;

                        case STOP_LOADING: