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

WKWebView: File upload causing uncaught exception if filename contains invalid URL characters #1874

Closed
lubos opened this issue Jan 8, 2021 · 0 comments · Fixed by #1876
Closed
Labels
Milestone

Comments

@lubos
Copy link
Contributor

lubos commented Jan 8, 2021

When viewing following HTML code using WKWebView

<input type="file">

And user selects a file which contains space character, the application will crash with NSInvalidArgumentException.

I think the issue is with RunOpenPanel function

public override void RunOpenPanel(wk.WKWebView webView, wk.WKOpenPanelParameters parameters, wk.WKFrameInfo frame, Action<NSUrl[]> completionHandler)
{
var openDlg = new OpenFileDialog();
if (openDlg.ShowDialog(Handler.Widget.ParentWindow) == DialogResult.Ok)
{
completionHandler(openDlg.Filenames.Select(r => new NSUrl(r)).ToArray());
}
else
{
completionHandler(null);
}
}

Before passing r variable to new NSUrl(r) we need to make sure r is URL encoded.

Or we should use fileURL function which returns NSUrl.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants