Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: WKWebview Custom Protocol #1113

Merged
merged 2 commits into from
Oct 21, 2020

Conversation

dr-bonez
Copy link
Contributor

@dr-bonez dr-bonez commented Oct 7, 2020

Description
In WKWebview (the webview for iOS), the Blob data type is not supported for non-http protocols. This can cause issues for custom browsers for iOS that use WKURLSchemeHandler. This change detects if the page is being hosted on a non-http URL scheme and will convert the Blob to an ArrayBuffer if so.

@dr-bonez dr-bonez force-pushed the fix/wkwebview-custom-protocol branch from 3ad4472 to 575966b Compare October 7, 2020 18:48
@o1egl
Copy link
Member

o1egl commented Oct 8, 2020

@dr-bonez Can you please explain how the procol there could be non http(s)?

@dr-bonez
Copy link
Contributor Author

dr-bonez commented Oct 8, 2020

Sure.
iOS is deprecating the UIWebview and replacing it with WKWebview. WKWebview will only let you override the transport protocol if you use a custom url scheme, so if a browser wants to do anything special with how requests are fetched, the page can't be accessed over http(s). For example, the Consulate browser for iOS uses a custom protocol (onion://) in order to use Tor as well as do network level caching.

@@ -85,6 +85,11 @@ export function download (format, ...files) {
export async function post (url, content = '', overwrite = false, onupload) {
url = removePrefix(url)

let bufferContent
if (content instanceof Blob && !['http:', 'https:'].includes(window.location.protocol)) {
Copy link
Member

@o1egl o1egl Oct 12, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think better would be to compare only prefix with startsWith.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that would be more performant however not strictly correct in what we are trying to catch. Someone could theoretically use a custom protocol http+foo: and that would cause this to break, as it is then considered a "non-http protocol" from iOS's standpoint, but would be considered an http protocol from filebrowser's.

@dr-bonez dr-bonez requested a review from o1egl October 13, 2020 18:00
@o1egl o1egl merged commit 0ac80e8 into filebrowser:master Oct 21, 2020
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.

None yet

2 participants