From 2d2ad4cb81c92e1f41406a2c08e4076713bf0ba5 Mon Sep 17 00:00:00 2001 From: jcesarmobile Date: Wed, 29 Jun 2022 04:36:55 +0200 Subject: [PATCH] fix: accept file cookies only if AndroidInsecureFileModeEnabled (#1449) --- .../org/apache/cordova/engine/SystemCookieManager.java | 8 +++++--- .../org/apache/cordova/engine/SystemWebViewEngine.java | 1 + 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/framework/src/org/apache/cordova/engine/SystemCookieManager.java b/framework/src/org/apache/cordova/engine/SystemCookieManager.java index df8cbac337..bc980356c6 100644 --- a/framework/src/org/apache/cordova/engine/SystemCookieManager.java +++ b/framework/src/org/apache/cordova/engine/SystemCookieManager.java @@ -19,8 +19,6 @@ Licensed to the Apache Software Foundation (ASF) under one package org.apache.cordova.engine; -import android.annotation.TargetApi; -import android.os.Build; import android.webkit.CookieManager; import android.webkit.WebView; @@ -35,10 +33,14 @@ public SystemCookieManager(WebView webview) { webView = webview; cookieManager = CookieManager.getInstance(); - cookieManager.setAcceptFileSchemeCookies(true); cookieManager.setAcceptThirdPartyCookies(webView, true); } + @SuppressWarnings("deprecation") + public void setAcceptFileSchemeCookies() { + cookieManager.setAcceptFileSchemeCookies(true); + } + public void setCookiesEnabled(boolean accept) { cookieManager.setAcceptCookie(accept); } diff --git a/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java b/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java index 71fa33dd1c..5ff1abfff6 100755 --- a/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java +++ b/framework/src/org/apache/cordova/engine/SystemWebViewEngine.java @@ -165,6 +165,7 @@ private void initWebViewSettings() { LOG.d(TAG, "Enabled insecure file access"); settings.setAllowFileAccess(true); settings.setAllowUniversalAccessFromFileURLs(true); + cookieManager.setAcceptFileSchemeCookies(); } settings.setMediaPlaybackRequiresUserGesture(false);