Skip to content

Stop re-enabling setAllowFileAccess after the explicit setAllowFileAccess(false)#126

Open
jim-daf wants to merge 1 commit into
martykan:masterfrom
jim-daf:fix-webview-file-access-reenable
Open

Stop re-enabling setAllowFileAccess after the explicit setAllowFileAccess(false)#126
jim-daf wants to merge 1 commit into
martykan:masterfrom
jim-daf:fix-webview-file-access-reenable

Conversation

@jim-daf

@jim-daf jim-daf commented May 13, 2026

Copy link
Copy Markdown

Closes #125.

MainActivity.setUpWebview does:

webSettings.setAllowFileAccess(false);
...
webSettings.setAppCachePath(cachePath);
webSettings.setAllowFileAccess(true);
webSettings.setAppCacheEnabled(true);

The first setAllowFileAccess(false) shows the intent: the WebView is pointed at m.youtube.com and does not need file:// access. The second setAllowFileAccess(true) sits inside the cache setup and reads as a refactor artifact. setAppCache* does not require file access.

Change

Drop the setAllowFileAccess(true) line so the initial setAllowFileAccess(false) decision holds. file:///android_asset/* loads remain permitted on every supported Android version regardless. No other WebView setting touched.

The downstream tobykurien/GoogleApps fork carries the same shape and a matching fix is open at tobykurien/GoogleApps#59.

Assisted-by: Claude (Anthropic)

…cess(false)

MainActivity.setUpWebview did:

    webSettings.setJavaScriptEnabled(true);
    webSettings.setJavaScriptCanOpenWindowsAutomatically(false);
    webSettings.setAllowFileAccess(false);

    webSettings.setDatabaseEnabled(true);
    ...
    webSettings.setAppCachePath(cachePath);
    webSettings.setAllowFileAccess(true);
    webSettings.setAppCacheEnabled(true);

The first setAllowFileAccess(false) shows the intent: the WebView is
loaded with YouTube (m.youtube.com) and never legitimately needs to
load file:// URLs. The setAllowFileAccess(true) call a few lines
later sits inside the cache-related setup and reads as a refactor
artifact rather than an intentional toggle. setAppCache does not
require file access.

Drop the second setAllowFileAccess(true) line so the initial
setAllowFileAccess(false) decision holds. file:///android_asset/*
loads remain permitted on every supported Android version
regardless of the flag.

Assisted-by: Claude (Anthropic)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MainActivity.setUpWebview re-enables setAllowFileAccess after explicitly setting it to false

1 participant