[iOS] Encode url for UIWebView so it doesn't fail with non-ascii characters (#2111)

* [Controls] Add reproduction for issue #1583

* [iOS] Encode url so it doesn't fail with non-ascii characters fixes #1583

* Update Issue1583_1.cs
This commit is contained in:
Rui Marinho 2018-03-15 22:32:14 +00:00 коммит произвёл GitHub
Родитель 3a3728f499
Коммит 14aa258915
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
3 изменённых файлов: 39 добавлений и 2 удалений

Просмотреть файл

@ -0,0 +1,35 @@
using Xamarin.Forms.CustomAttributes;
using Xamarin.Forms.Internals;
#if UITEST
using Xamarin.UITest;
using NUnit.Framework;
#endif
namespace Xamarin.Forms.Controls.Issues
{
[Preserve(AllMembers = true)]
[Issue(IssueTracker.Github, 1583, "WebView fails to load from urlwebviewsource with non-ascii characters (works with Uri)", PlatformAffected.iOS, issueTestNumber: 1)]
public class Issue1583 : TestContentPage
{
protected override void Init()
{
var webview = new WebView
{
AutomationId = "webview"
};
webview.Source = new UrlWebViewSource { Url = "https://www.google.no/maps/place/Skøyen" };
Content = webview;
}
#if UITEST
[Test]
public void Issue1583Test ()
{
RunningApp.WaitForElement (q => q.Marked ("webview"));
RunningApp.Screenshot ("I didn't crash and i can see Skøyen");
}
#endif
}
}

Просмотреть файл

@ -691,6 +691,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla31688.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla40092.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1426.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1583_1.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Issue1323.cs" />
</ItemGroup>
<ItemGroup>
@ -859,7 +860,7 @@
<ItemGroup>
<EmbeddedResource Include="$(MSBuildThisFileDirectory)Bugzilla60045.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
<Generator>MSBuild:UpdateDesignTimeXaml</Generator>
</EmbeddedResource>
</ItemGroup>
</Project>

Просмотреть файл

@ -79,7 +79,8 @@ namespace Xamarin.Forms.Platform.iOS
public void LoadUrl(string url)
{
LoadRequest(new NSUrlRequest(new NSUrl(url)));
var encodedStringUrl = new NSString(url).CreateStringByAddingPercentEscapes(NSStringEncoding.UTF8);
LoadRequest(new NSUrlRequest(new NSUrl(encodedStringUrl)));
}
public override void LayoutSubviews()