WebView fails to load from urlwebviewsource with non-ascii characters (works with Uri) #1583
Comments
Hmmm, previous behavior (in Forms 2.x) was consistent: URL was not escaped on both platforms (iOS and Android), but now (Forms 3.0) on iOS provided URL is escaped, but on Android - not... It makes me crazy... I prefer the old one... |
The webview is not a browser, non-ascii character should escaped by user. |
We are going to rever this fix, @pfaucon I think you will need to encode the url before sending it to forms |
I think the inconsistency argument presented by @vladbilyk is a bit weak, it would not be more difficult to escape both iOS and Android. @capraynor's argument is also weak/wrong. webview is rendererd on iOS using a UIWebView, I don't see a use case where an unescaped url has value, particularly when we know that on iOS it will error out, and the error provided is not very helpful. I'm not certain if Android will auto-escape the URL but it seems unlikely that escaping it will cause harm. Is there a use case for having an unescaped url (or errors caused by escaping it)? edit: the error provided is not completely useless, but it is not very helpful. |
As a second counter to @vladbilyk's argument while XF doesn't escape the urls when loading on Android, someone does, as the page loads successfully in a new project using XF 2.5.0.121934 (but still fails in iOS as expected). I would then argue that fixing the bug in iOS in fact normalizes the platform more (instead of crash/work, it works on both platforms). |
Description
When loading a WebView with the 'Source' set as a Uri the webview is quite tolerant. If the 'Source' is setting using a UrlWebviewSource non-ascii characters cause the view to throw an exception
Steps to Reproduce
example :
Expected Behavior
it should escape the url as needed and load without exception. When setting the source with a new Uri object it behaves as expected.
Actual Behavior
Could not initialize an instance of the type 'Foundation.NSUrl': the native 'initWithString:' method returned nil.
It is possible to ignore this condition by setting MonoTouch.ObjCRuntime.Class.ThrowOnInitFailure to false.
Basic Information
Currently on Xamarin Forms
2.5.0.121934
The text was updated successfully, but these errors were encountered: