Allow WebView attachment document loads
This commit is contained in:
@@ -39,6 +39,12 @@ final class AttachmentPreview {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static boolean isWebViewInternalDocumentUrl(String url) {
|
||||||
|
if (url == null) return false;
|
||||||
|
String value = url.trim().toLowerCase(java.util.Locale.ROOT);
|
||||||
|
return value.equals("about:blank") || value.startsWith("data:text/html");
|
||||||
|
}
|
||||||
|
|
||||||
static String xmlPreviewDocument(String xml) {
|
static String xmlPreviewDocument(String xml) {
|
||||||
return "<!doctype html><html><head><meta charset=\"utf-8\">"
|
return "<!doctype html><html><head><meta charset=\"utf-8\">"
|
||||||
+ "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"
|
+ "<meta name=\"viewport\" content=\"width=device-width, initial-scale=1\">"
|
||||||
|
|||||||
@@ -9572,11 +9572,11 @@ private class AttachmentPreviewWebViewClient(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse? {
|
override fun shouldInterceptRequest(view: WebView, request: WebResourceRequest): WebResourceResponse? {
|
||||||
val url = request.url?.toString().orEmpty()
|
return null
|
||||||
return if (AttachmentPreview.isLocalPreviewUrl(url)) null else WebResourceResponse("text/plain", "UTF-8", null)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleNavigation(url: String): Boolean {
|
private fun handleNavigation(url: String): Boolean {
|
||||||
|
if (AttachmentPreview.isWebViewInternalDocumentUrl(url)) return false
|
||||||
if (AttachmentPreview.isLocalPreviewUrl(url)) return false
|
if (AttachmentPreview.isLocalPreviewUrl(url)) return false
|
||||||
openExternalUrl(context, url)
|
openExternalUrl(context, url)
|
||||||
return true
|
return true
|
||||||
|
|||||||
Reference in New Issue
Block a user