cordova-plugin-inappbrowser
cordova-plugin-inappbrowser copied to clipboard
fix(ios): Allow loading of external local files from the same directory as loaded local html
Platforms affected
iOS
Motivation and Context
Many applications rely on ability to display local resources using inappbrowser. WKWebView implementation introduced additional security which needs to be handled.
Fixes #657 Improves on #883
Description
Pull request #693 made loading of local html files is possible in v4 WKWebView branch. However - how it was implemented only enabled opening of a single html file in IAB without its external resources (eg. css/images/javascript) throwing didStartProvisionalNavigation
(not allowed).
As per Apple documentation loadFileURL
accepts 2 parameters:
-
URL
- The file URL to navigate to. -
readAccessURL
-The URL to allow read access to.
If readAccessURL references a single file, only that file may be loaded by WebKit. If readAccessURL references a directory, files inside that file may be loaded by WebKit.
Now, I extract directory from passed url and pass it to the loadFileURL
method making external local content from the same directory as loaded html - loadable.
Testing
npm test pass. multiple builds on multiple real devices with and without notch.
Checklist
- [x] I've run the tests to see all new and existing tests pass
- [ ] I added automated test coverage as appropriate for this change
- [x] Commit is prefixed with
(platform)
if this change only applies to one platform (e.g.(android)
) - [x] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
- [ ] I've updated the documentation if necessary
Any hint about when will this be merged? Its a show stopper for our migration to cordova-ios 6 / wkwebview. Thx.
Yes, I have 4 working apps in production via AppStore. They passed Apple. 😅
When we ask for "example apps" we mean a github repository of a cordova app (or zip file) where the issue can be reproduced and then can be used to verify the fix.
When we ask for "example apps" we mean a github repository of a cordova app (or zip file) where the issue can be reproduced and then can be used to verify the fix.
Sorry I do not have source code publicly available. But this is so easily reproduced. I really cannot believe it how long it took for someone to notice this PR. There are many IOS issues related to this in Github Issues for this project.
I am having this problem too. With this fix are we supposed to be able to use cordova.InAppBrowser.open('help/signin.html', '_blank'), where help is a folder sibling to index.html? Trying to get this to work with no luck. Any help would be appreciated.