From 098dec5a013e96fd3963f994eecf3b28f44b13a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Gerlei?= Date: Wed, 31 Jul 2024 00:03:04 +0200 Subject: [PATCH 1/3] Fix opaque origin demo (#24) * Load example.com in opaque origin demo and slightly improve success display * Only block data URIs in loadUrl so opaque origin demo works again --- .../main/java/dev/gerlot/securewebview/SecureWebView.java | 8 ++++---- sample/src/main/assets/same_origin_test.html | 4 ++-- .../securewebview/sample/demos/OpaqueOriginFragment.kt | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/library/src/main/java/dev/gerlot/securewebview/SecureWebView.java b/library/src/main/java/dev/gerlot/securewebview/SecureWebView.java index 9295a9f..e75b297 100644 --- a/library/src/main/java/dev/gerlot/securewebview/SecureWebView.java +++ b/library/src/main/java/dev/gerlot/securewebview/SecureWebView.java @@ -222,15 +222,15 @@ private void init(final Context context) { } private boolean shouldBlockRequest(final Uri uri) { - return shouldBlockRequest(uri, false, false); + return shouldBlockRequest(uri, true, false); } - private boolean shouldBlockRequest(final Uri uri, boolean allowDataUrl, boolean allowJavaScript) { + private boolean shouldBlockRequest(final Uri uri, boolean allowDataUri, boolean allowJavaScript) { if ("http".equals(uri.getScheme())) { return true; } - if (!allowDataUrl && "data".equals(uri.getScheme())) { + if (!allowDataUri && "data".equals(uri.getScheme())) { return true; } @@ -309,7 +309,7 @@ public boolean getAllowContentAccess() { return webView.getSettings().getAllowContentAccess(); } - public void loadDataWithBaseURL(String baseUrl,String data, String mimeType, String encoding, String historyUrl) { + public void loadDataWithBaseURL(String baseUrl, String data, String mimeType, String encoding, String historyUrl) { webView.loadDataWithBaseURL(baseUrl, data, mimeType, encoding, historyUrl); } diff --git a/sample/src/main/assets/same_origin_test.html b/sample/src/main/assets/same_origin_test.html index 8f4c42a..f3ab8c1 100644 --- a/sample/src/main/assets/same_origin_test.html +++ b/sample/src/main/assets/same_origin_test.html @@ -11,9 +11,9 @@