Skip to content
This repository was archived by the owner on Aug 31, 2021. It is now read-only.

Commit 9d5fc35

Browse files
committed
[[ Bug 22816 ]] Fix permissions when loading a local html file
This patch uses the `loadFileURL:allowingReadAccessToURL:` instance method of the WKWebView class to load a local html file. This fixes an issue with insufficient permissions on iOS 12 devices that prevented the html file from being loaded.
1 parent 208cdd1 commit 9d5fc35

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

docs/notes/bugfix-22816.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Fix permissions when loading a local html file on iOS 12

libbrowser/src/libbrowser_wkwebview.mm

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,16 @@ - (void) loadRequest:(MCWKWebViewLoadRequest *)request inWebView:(WKWebView *)we
16181618
MCBrowserRunBlockOnMainFiber(^{
16191619
if (request.htmlText == nil)
16201620
{
1621-
[webView loadRequest:[NSURLRequest requestWithURL:request.url]];
1621+
if (![request.url isFileURL])
1622+
[webView loadRequest:[NSURLRequest requestWithURL:request.url]];
1623+
else
1624+
{
1625+
NSURL *t_docs_dir_url = [[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject];
1626+
if ([request.url.absoluteString hasPrefix:t_docs_dir_url.absoluteString])
1627+
[webView loadFileURL:request.url allowingReadAccessToURL:t_docs_dir_url];
1628+
else
1629+
[webView loadFileURL:request.url allowingReadAccessToURL:request.url.URLByDeletingLastPathComponent];
1630+
}
16221631
}
16231632
else
16241633
{

0 commit comments

Comments
 (0)