From cb8ae1acf6c6a35f60c3c976c87e7fcd60d31696 Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Wed, 8 Jan 2025 15:40:10 +0530 Subject: [PATCH 1/9] Fix code and test case commit --- .../TestCases.HostApp/Issues/Issue26843.cs | 58 +++++++++++++++++++ .../Tests/Issues/Issue26843.cs | 22 +++++++ src/Core/src/Platform/Android/MauiWebView.cs | 2 +- 3 files changed, 81 insertions(+), 1 deletion(-) create mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue26843.cs create mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26843.cs diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue26843.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue26843.cs new file mode 100644 index 000000000000..9b65a7851502 --- /dev/null +++ b/src/Controls/tests/TestCases.HostApp/Issues/Issue26843.cs @@ -0,0 +1,58 @@ +namespace Maui.Controls.Sample.Issues; + +[XamlCompilation(XamlCompilationOptions.Compile)] +[Issue(IssueTracker.Github, 26843, "WebView Fails to Load URLs with Certain Encoded Characters on Android", PlatformAffected.Android)] + public partial class Issue26843 : ContentPage + { + private Label navigationResultLabel; + public Issue26843() + { + navigationResultLabel = new Label + { + AutomationId = "NavigationResultLabel", + HorizontalOptions = LayoutOptions.Center, + VerticalOptions = LayoutOptions.Center, + TextColor = Colors.Black, + FontSize = 14 + }; + + var webView = new WebView + { + AutomationId = "WebView", + ZIndex = 1 + }; + + webView.Source = "https://github.com/SuthiYuvaraj/maui/blob/390e4cd1c5eed59ecaf1fcd37975e7f6f5422d6d/src/Controls/tests/TestCases.HostApp/Resources/Raw/01-A%C4%9F-Sistem%20Bilgi%20G%C3%BCvenli%C4%9Fi%20Md/dotnet%20maui.pdf"; + webView.Navigated += OnNavigated; + + var layout = new Grid + { + RowDefinitions = + { + new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, + new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } + }, + Children = { + navigationResultLabel, + webView + } + }; + + Grid.SetRow(navigationResultLabel, 0); + Grid.SetRow(webView, 1); + + Content = layout; + } + + private void OnNavigated(object sender, WebNavigatedEventArgs e) + { + if (e.Result == WebNavigationResult.Success) + { + navigationResultLabel.Text = $"Successfully navigated to the encoded URL"; + } + else + { + navigationResultLabel.Text = $"Failed to navigate to the encoded URL"; + } + } + } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26843.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26843.cs new file mode 100644 index 000000000000..cf8a923f7994 --- /dev/null +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26843.cs @@ -0,0 +1,22 @@ +using NUnit.Framework; +using UITest.Appium; +using UITest.Core; + +namespace Microsoft.Maui.TestCases.Tests.Issues; + + internal class Issue26843 : _IssuesUITest + { + public Issue26843(TestDevice device) : base(device) { } + + public override string Issue => "WebView Fails to Load URLs with Certain Encoded Characters on Android"; + + [Test] + [Category(UITestCategories.WebView)] + public void WebViewShouldLoadEncodedUrl() + { + var label = App.WaitForElement("NavigationResultLabel"); + App.WaitForElement("WebView"); + Assert.That(label.ReadText(), Is.EqualTo("Successfully navigated to the encoded URL")); + } + } + diff --git a/src/Core/src/Platform/Android/MauiWebView.cs b/src/Core/src/Platform/Android/MauiWebView.cs index 807e7d705e83..85131d3f4c48 100644 --- a/src/Core/src/Platform/Android/MauiWebView.cs +++ b/src/Core/src/Platform/Android/MauiWebView.cs @@ -32,7 +32,7 @@ void IWebViewDelegate.LoadUrl(string? url) _handler.CurrentNavigationEvent = WebNavigationEvent.NewPage; } - if (url != null && !url.StartsWith('/') && !Uri.IsWellFormedUriString(url, UriKind.Absolute)) + if (url != null && !url.StartsWith('/') && !Uri.TryCreate(url, UriKind.Absolute, out _)) { // URLs like "index.html" can't possibly load, so try "file:///android_asset/index.html" url = AssetBaseUrl + url; From f59a7ba5263f7e2dcbe6d5c8236e9fe37c626e20 Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Wed, 8 Jan 2025 16:15:30 +0530 Subject: [PATCH 2/9] test case code updated --- .../tests/TestCases.Shared.Tests/Tests/Issues/Issue26843.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26843.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26843.cs index cf8a923f7994..560d4bf84732 100644 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26843.cs +++ b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26843.cs @@ -16,7 +16,7 @@ public void WebViewShouldLoadEncodedUrl() { var label = App.WaitForElement("NavigationResultLabel"); App.WaitForElement("WebView"); - Assert.That(label.ReadText(), Is.EqualTo("Successfully navigated to the encoded URL")); + Assert.That(label.GetText(), Is.EqualTo("Successfully navigated to the encoded URL")); } } From 3032e5a8ecad31f1d94c6e3075fddb427c549abe Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Sun, 12 Jan 2025 18:34:20 +0530 Subject: [PATCH 3/9] removed ui tests as it used user name included url --- .../TestCases.HostApp/Issues/Issue26843.cs | 58 ------------------- .../Tests/Issues/Issue26843.cs | 22 ------- 2 files changed, 80 deletions(-) delete mode 100644 src/Controls/tests/TestCases.HostApp/Issues/Issue26843.cs delete mode 100644 src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26843.cs diff --git a/src/Controls/tests/TestCases.HostApp/Issues/Issue26843.cs b/src/Controls/tests/TestCases.HostApp/Issues/Issue26843.cs deleted file mode 100644 index 9b65a7851502..000000000000 --- a/src/Controls/tests/TestCases.HostApp/Issues/Issue26843.cs +++ /dev/null @@ -1,58 +0,0 @@ -namespace Maui.Controls.Sample.Issues; - -[XamlCompilation(XamlCompilationOptions.Compile)] -[Issue(IssueTracker.Github, 26843, "WebView Fails to Load URLs with Certain Encoded Characters on Android", PlatformAffected.Android)] - public partial class Issue26843 : ContentPage - { - private Label navigationResultLabel; - public Issue26843() - { - navigationResultLabel = new Label - { - AutomationId = "NavigationResultLabel", - HorizontalOptions = LayoutOptions.Center, - VerticalOptions = LayoutOptions.Center, - TextColor = Colors.Black, - FontSize = 14 - }; - - var webView = new WebView - { - AutomationId = "WebView", - ZIndex = 1 - }; - - webView.Source = "https://github.com/SuthiYuvaraj/maui/blob/390e4cd1c5eed59ecaf1fcd37975e7f6f5422d6d/src/Controls/tests/TestCases.HostApp/Resources/Raw/01-A%C4%9F-Sistem%20Bilgi%20G%C3%BCvenli%C4%9Fi%20Md/dotnet%20maui.pdf"; - webView.Navigated += OnNavigated; - - var layout = new Grid - { - RowDefinitions = - { - new RowDefinition { Height = new GridLength(1, GridUnitType.Auto) }, - new RowDefinition { Height = new GridLength(1, GridUnitType.Star) } - }, - Children = { - navigationResultLabel, - webView - } - }; - - Grid.SetRow(navigationResultLabel, 0); - Grid.SetRow(webView, 1); - - Content = layout; - } - - private void OnNavigated(object sender, WebNavigatedEventArgs e) - { - if (e.Result == WebNavigationResult.Success) - { - navigationResultLabel.Text = $"Successfully navigated to the encoded URL"; - } - else - { - navigationResultLabel.Text = $"Failed to navigate to the encoded URL"; - } - } - } diff --git a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26843.cs b/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26843.cs deleted file mode 100644 index 560d4bf84732..000000000000 --- a/src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue26843.cs +++ /dev/null @@ -1,22 +0,0 @@ -using NUnit.Framework; -using UITest.Appium; -using UITest.Core; - -namespace Microsoft.Maui.TestCases.Tests.Issues; - - internal class Issue26843 : _IssuesUITest - { - public Issue26843(TestDevice device) : base(device) { } - - public override string Issue => "WebView Fails to Load URLs with Certain Encoded Characters on Android"; - - [Test] - [Category(UITestCategories.WebView)] - public void WebViewShouldLoadEncodedUrl() - { - var label = App.WaitForElement("NavigationResultLabel"); - App.WaitForElement("WebView"); - Assert.That(label.GetText(), Is.EqualTo("Successfully navigated to the encoded URL")); - } - } - From 80e8171c720cae0418c64a9046da097a678f14eb Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Fri, 17 Jan 2025 20:43:44 +0530 Subject: [PATCH 4/9] updated unit test case --- src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs b/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs index ec32603a1a4e..f16f8d604ce4 100644 --- a/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs +++ b/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs @@ -161,5 +161,16 @@ public void TestSettingOfCookie() Assert.NotNull(defaultWebView.Cookies); } + + [Fact] + public void TestUrlWithTurkishCharacters() + { + + string testUrl = "https://example.com/test-Ağ-Sistem%20Bilgi%20Güvenliği%20Md/Guide.pdf"; + + bool isWellFormed = Uri.TryCreate(testUrl, UriKind.Absolute, out _); + + Assert.True(isWellFormed, "The URL with Turkish characters should be well-formed."); + } } } From 831ea9d4df4aeedfcd9f645bc81670678b90a50a Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Tue, 21 Jan 2025 21:47:43 +0530 Subject: [PATCH 5/9] updated fix and unit test case --- .../tests/Core.UnitTests/WebViewUnitTests.cs | 20 ++++++++++++------- src/Core/src/Platform/Android/MauiWebView.cs | 2 +- src/Core/src/Platform/WebViewHelper.cs | 11 ++++++++++ .../net-android/PublicAPI.Unshipped.txt | 2 ++ .../PublicAPI/net-ios/PublicAPI.Unshipped.txt | 2 ++ .../net-maccatalyst/PublicAPI.Unshipped.txt | 2 ++ .../net-tizen/PublicAPI.Unshipped.txt | 2 ++ .../net-windows/PublicAPI.Unshipped.txt | 2 ++ .../src/PublicAPI/net/PublicAPI.Unshipped.txt | 2 ++ .../netstandard/PublicAPI.Unshipped.txt | 2 ++ .../netstandard2.0/PublicAPI.Unshipped.txt | 2 ++ 11 files changed, 41 insertions(+), 8 deletions(-) create mode 100644 src/Core/src/Platform/WebViewHelper.cs diff --git a/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs b/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs index f16f8d604ce4..7bb125a01311 100644 --- a/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs +++ b/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs @@ -7,6 +7,7 @@ using Microsoft.Maui.Controls.PlatformConfiguration.WindowsSpecific; using Microsoft.Maui.Graphics; using Xunit; +using Microsoft.Maui.Platform; using WindowsOS = Microsoft.Maui.Controls.PlatformConfiguration.Windows; namespace Microsoft.Maui.Controls.Core.UnitTests @@ -163,14 +164,19 @@ public void TestSettingOfCookie() } [Fact] - public void TestUrlWithTurkishCharacters() - { + public void TestUrlWithNonWesternCharacters() + { + // Arrange + // This test validates that URLs with non-Western characters (e.g., "Ğ" and spaces encoded as "%20") + // are correctly identified as absolute URLs and not treated as relative URLs. + + string finalUrl = "https://example.com/test-Ağ-Sistem%20Bilgi%20Güvenliği%20Md/Guide.pdf"; - string testUrl = "https://example.com/test-Ağ-Sistem%20Bilgi%20Güvenliği%20Md/Guide.pdf"; - - bool isWellFormed = Uri.TryCreate(testUrl, UriKind.Absolute, out _); + // Act + bool valid = WebViewHelper.IsRelativeUrl(finalUrl); - Assert.True(isWellFormed, "The URL with Turkish characters should be well-formed."); - } + // Assert + Assert.False(valid, "The URL was identified as a relative URL"); + } } } diff --git a/src/Core/src/Platform/Android/MauiWebView.cs b/src/Core/src/Platform/Android/MauiWebView.cs index 85131d3f4c48..4598c3ea3c3c 100644 --- a/src/Core/src/Platform/Android/MauiWebView.cs +++ b/src/Core/src/Platform/Android/MauiWebView.cs @@ -32,7 +32,7 @@ void IWebViewDelegate.LoadUrl(string? url) _handler.CurrentNavigationEvent = WebNavigationEvent.NewPage; } - if (url != null && !url.StartsWith('/') && !Uri.TryCreate(url, UriKind.Absolute, out _)) + if (url is not null && WebViewHelper.IsRelativeUrl(url)) { // URLs like "index.html" can't possibly load, so try "file:///android_asset/index.html" url = AssetBaseUrl + url; diff --git a/src/Core/src/Platform/WebViewHelper.cs b/src/Core/src/Platform/WebViewHelper.cs new file mode 100644 index 000000000000..f174542fa70f --- /dev/null +++ b/src/Core/src/Platform/WebViewHelper.cs @@ -0,0 +1,11 @@ +using System; + +namespace Microsoft.Maui.Platform; + +public static class WebViewHelper +{ + public static bool IsRelativeUrl(string url) + { + return !url.StartsWith("/") && !Uri.TryCreate(url, UriKind.Absolute, out _); + } +} \ No newline at end of file diff --git a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index b321ce001d0b..e0e7a4df3f33 100644 --- a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -53,6 +53,8 @@ Microsoft.Maui.Platform.MauiHybridWebViewClient.MauiHybridWebViewClient(Microsof Microsoft.Maui.Platform.MauiMaterialButton.MauiMaterialButton(Android.Content.Context! context, Android.Util.IAttributeSet? attrs, int defStyleAttr) -> void Microsoft.Maui.Platform.MauiMaterialButton.MauiMaterialButton(Android.Content.Context! context, Android.Util.IAttributeSet? attrs) -> void Microsoft.Maui.Platform.MauiMaterialButton.MauiMaterialButton(nint javaReference, Android.Runtime.JniHandleOwnership transfer) -> void +Microsoft.Maui.Platform.WebViewHelper +static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.RenderProcessGoneDetail.get -> Android.Webkit.RenderProcessGoneDetail? diff --git a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index 2f50488fb79a..c656159e2149 100644 --- a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -47,6 +47,8 @@ Microsoft.Maui.Platform.MauiHybridWebView.MauiHybridWebView(Microsoft.Maui.Handl Microsoft.Maui.Platform.MauiHybridWebView.SendRawMessage(string! rawMessage) -> void Microsoft.Maui.Platform.MauiWKWebView.ContentProcessDidTerminate(WebKit.WKWebView! webView) -> void Microsoft.Maui.Platform.UIWindowExtensions +Microsoft.Maui.Platform.WebViewHelper +static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.Sender.get -> WebKit.WKWebView! diff --git a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 21e375ed2cdb..823b9a70f9e7 100644 --- a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -47,6 +47,8 @@ Microsoft.Maui.Platform.MauiHybridWebView.MauiHybridWebView(Microsoft.Maui.Handl Microsoft.Maui.Platform.MauiHybridWebView.SendRawMessage(string! rawMessage) -> void Microsoft.Maui.Platform.MauiWKWebView.ContentProcessDidTerminate(WebKit.WKWebView! webView) -> void Microsoft.Maui.Platform.UIWindowExtensions +Microsoft.Maui.Platform.WebViewHelper +static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.Sender.get -> WebKit.WKWebView! diff --git a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index 6e3939ec4fd4..b3385afddf62 100644 --- a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -42,6 +42,8 @@ Microsoft.Maui.ITitleBar.Title.get -> string? Microsoft.Maui.IWebView.ProcessTerminated(Microsoft.Maui.WebProcessTerminatedEventArgs! args) -> void *REMOVED*Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView! Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView? +Microsoft.Maui.Platform.WebViewHelper +static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.WebProcessTerminatedEventArgs() -> void diff --git a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index 415d7a580c21..408e9bfac336 100644 --- a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -47,6 +47,8 @@ Microsoft.Maui.Platform.MauiHybridWebView Microsoft.Maui.Platform.MauiHybridWebView.MauiHybridWebView(Microsoft.Maui.Handlers.HybridWebViewHandler! handler) -> void Microsoft.Maui.Platform.MauiHybridWebView.RunAfterInitialize(System.Action! action) -> void Microsoft.Maui.Platform.MauiHybridWebView.SendRawMessage(string! rawMessage) -> void +Microsoft.Maui.Platform.WebViewHelper +static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.CoreWebView2ProcessFailedEventArgs.get -> Microsoft.Web.WebView2.Core.CoreWebView2ProcessFailedEventArgs! diff --git a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt index 8f3d85f43b4e..f98ec3194514 100644 --- a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -42,6 +42,8 @@ Microsoft.Maui.ITitleBar.Title.get -> string? Microsoft.Maui.IWebView.ProcessTerminated(Microsoft.Maui.WebProcessTerminatedEventArgs! args) -> void *REMOVED*Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView! Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView? +Microsoft.Maui.Platform.WebViewHelper +static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.WebProcessTerminatedEventArgs() -> void diff --git a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index 8f3d85f43b4e..f98ec3194514 100644 --- a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -42,6 +42,8 @@ Microsoft.Maui.ITitleBar.Title.get -> string? Microsoft.Maui.IWebView.ProcessTerminated(Microsoft.Maui.WebProcessTerminatedEventArgs! args) -> void *REMOVED*Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView! Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView? +Microsoft.Maui.Platform.WebViewHelper +static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.WebProcessTerminatedEventArgs() -> void diff --git a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index 8f3d85f43b4e..f98ec3194514 100644 --- a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -42,6 +42,8 @@ Microsoft.Maui.ITitleBar.Title.get -> string? Microsoft.Maui.IWebView.ProcessTerminated(Microsoft.Maui.WebProcessTerminatedEventArgs! args) -> void *REMOVED*Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView! Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView? +Microsoft.Maui.Platform.WebViewHelper +static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.WebProcessTerminatedEventArgs() -> void From 36dcf775c36d921a054e10b4047f18e048ad8dc3 Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Wed, 22 Jan 2025 12:39:38 +0530 Subject: [PATCH 6/9] updated the new class access specifier. --- src/Core/src/Platform/WebViewHelper.cs | 4 ++-- src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt | 2 -- src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt | 2 -- .../src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | 2 -- src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt | 2 -- src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt | 2 -- src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt | 2 -- src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt | 2 -- src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt | 2 -- 9 files changed, 2 insertions(+), 18 deletions(-) diff --git a/src/Core/src/Platform/WebViewHelper.cs b/src/Core/src/Platform/WebViewHelper.cs index f174542fa70f..e5cfbd07de68 100644 --- a/src/Core/src/Platform/WebViewHelper.cs +++ b/src/Core/src/Platform/WebViewHelper.cs @@ -2,9 +2,9 @@ namespace Microsoft.Maui.Platform; -public static class WebViewHelper +internal static class WebViewHelper { - public static bool IsRelativeUrl(string url) + internal static bool IsRelativeUrl(string url) { return !url.StartsWith("/") && !Uri.TryCreate(url, UriKind.Absolute, out _); } diff --git a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt index e0e7a4df3f33..b321ce001d0b 100644 --- a/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt @@ -53,8 +53,6 @@ Microsoft.Maui.Platform.MauiHybridWebViewClient.MauiHybridWebViewClient(Microsof Microsoft.Maui.Platform.MauiMaterialButton.MauiMaterialButton(Android.Content.Context! context, Android.Util.IAttributeSet? attrs, int defStyleAttr) -> void Microsoft.Maui.Platform.MauiMaterialButton.MauiMaterialButton(Android.Content.Context! context, Android.Util.IAttributeSet? attrs) -> void Microsoft.Maui.Platform.MauiMaterialButton.MauiMaterialButton(nint javaReference, Android.Runtime.JniHandleOwnership transfer) -> void -Microsoft.Maui.Platform.WebViewHelper -static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.RenderProcessGoneDetail.get -> Android.Webkit.RenderProcessGoneDetail? diff --git a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt index c656159e2149..2f50488fb79a 100644 --- a/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt @@ -47,8 +47,6 @@ Microsoft.Maui.Platform.MauiHybridWebView.MauiHybridWebView(Microsoft.Maui.Handl Microsoft.Maui.Platform.MauiHybridWebView.SendRawMessage(string! rawMessage) -> void Microsoft.Maui.Platform.MauiWKWebView.ContentProcessDidTerminate(WebKit.WKWebView! webView) -> void Microsoft.Maui.Platform.UIWindowExtensions -Microsoft.Maui.Platform.WebViewHelper -static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.Sender.get -> WebKit.WKWebView! diff --git a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt index 823b9a70f9e7..21e375ed2cdb 100644 --- a/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt @@ -47,8 +47,6 @@ Microsoft.Maui.Platform.MauiHybridWebView.MauiHybridWebView(Microsoft.Maui.Handl Microsoft.Maui.Platform.MauiHybridWebView.SendRawMessage(string! rawMessage) -> void Microsoft.Maui.Platform.MauiWKWebView.ContentProcessDidTerminate(WebKit.WKWebView! webView) -> void Microsoft.Maui.Platform.UIWindowExtensions -Microsoft.Maui.Platform.WebViewHelper -static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.Sender.get -> WebKit.WKWebView! diff --git a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt index b3385afddf62..6e3939ec4fd4 100644 --- a/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt @@ -42,8 +42,6 @@ Microsoft.Maui.ITitleBar.Title.get -> string? Microsoft.Maui.IWebView.ProcessTerminated(Microsoft.Maui.WebProcessTerminatedEventArgs! args) -> void *REMOVED*Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView! Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView? -Microsoft.Maui.Platform.WebViewHelper -static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.WebProcessTerminatedEventArgs() -> void diff --git a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt index 408e9bfac336..415d7a580c21 100644 --- a/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt @@ -47,8 +47,6 @@ Microsoft.Maui.Platform.MauiHybridWebView Microsoft.Maui.Platform.MauiHybridWebView.MauiHybridWebView(Microsoft.Maui.Handlers.HybridWebViewHandler! handler) -> void Microsoft.Maui.Platform.MauiHybridWebView.RunAfterInitialize(System.Action! action) -> void Microsoft.Maui.Platform.MauiHybridWebView.SendRawMessage(string! rawMessage) -> void -Microsoft.Maui.Platform.WebViewHelper -static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.CoreWebView2ProcessFailedEventArgs.get -> Microsoft.Web.WebView2.Core.CoreWebView2ProcessFailedEventArgs! diff --git a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt index f98ec3194514..8f3d85f43b4e 100644 --- a/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt @@ -42,8 +42,6 @@ Microsoft.Maui.ITitleBar.Title.get -> string? Microsoft.Maui.IWebView.ProcessTerminated(Microsoft.Maui.WebProcessTerminatedEventArgs! args) -> void *REMOVED*Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView! Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView? -Microsoft.Maui.Platform.WebViewHelper -static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.WebProcessTerminatedEventArgs() -> void diff --git a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt index f98ec3194514..8f3d85f43b4e 100644 --- a/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt @@ -42,8 +42,6 @@ Microsoft.Maui.ITitleBar.Title.get -> string? Microsoft.Maui.IWebView.ProcessTerminated(Microsoft.Maui.WebProcessTerminatedEventArgs! args) -> void *REMOVED*Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView! Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView? -Microsoft.Maui.Platform.WebViewHelper -static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.WebProcessTerminatedEventArgs() -> void diff --git a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt index f98ec3194514..8f3d85f43b4e 100644 --- a/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt +++ b/src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt @@ -42,8 +42,6 @@ Microsoft.Maui.ITitleBar.Title.get -> string? Microsoft.Maui.IWebView.ProcessTerminated(Microsoft.Maui.WebProcessTerminatedEventArgs! args) -> void *REMOVED*Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView! Microsoft.Maui.IWindow.Content.get -> Microsoft.Maui.IView? -Microsoft.Maui.Platform.WebViewHelper -static Microsoft.Maui.Platform.WebViewHelper.IsRelativeUrl(string! url) -> bool Microsoft.Maui.TextAlignment.Justify = 3 -> Microsoft.Maui.TextAlignment Microsoft.Maui.WebProcessTerminatedEventArgs Microsoft.Maui.WebProcessTerminatedEventArgs.WebProcessTerminatedEventArgs() -> void From ac292501e866fb73b982957d28e47f2a07bb869a Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Wed, 22 Jan 2025 12:46:37 +0530 Subject: [PATCH 7/9] Removed unit test descriptions --- src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs b/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs index 7bb125a01311..5f37763e530e 100644 --- a/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs +++ b/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs @@ -166,16 +166,13 @@ public void TestSettingOfCookie() [Fact] public void TestUrlWithNonWesternCharacters() { - // Arrange // This test validates that URLs with non-Western characters (e.g., "Ğ" and spaces encoded as "%20") // are correctly identified as absolute URLs and not treated as relative URLs. string finalUrl = "https://example.com/test-Ağ-Sistem%20Bilgi%20Güvenliği%20Md/Guide.pdf"; - // Act bool valid = WebViewHelper.IsRelativeUrl(finalUrl); - // Assert Assert.False(valid, "The URL was identified as a relative URL"); } } From 2c05919bc855ba301850c7ade7c1a45d7acec053 Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Wed, 22 Jan 2025 15:53:22 +0530 Subject: [PATCH 8/9] Fix updated --- src/Core/src/Platform/WebViewHelper.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Core/src/Platform/WebViewHelper.cs b/src/Core/src/Platform/WebViewHelper.cs index e5cfbd07de68..8c6931f0c476 100644 --- a/src/Core/src/Platform/WebViewHelper.cs +++ b/src/Core/src/Platform/WebViewHelper.cs @@ -6,6 +6,6 @@ internal static class WebViewHelper { internal static bool IsRelativeUrl(string url) { - return !url.StartsWith("/") && !Uri.TryCreate(url, UriKind.Absolute, out _); + return !url.StartsWith('/') && !Uri.TryCreate(url, UriKind.Absolute, out _); } } \ No newline at end of file From 05f24f49c86cdb413a9320e7a7674c3e46ba96b5 Mon Sep 17 00:00:00 2001 From: praveenkumarkarunanithi Date: Wed, 22 Jan 2025 18:32:23 +0530 Subject: [PATCH 9/9] updated the unit test case --- .../tests/Core.UnitTests/WebViewUnitTests.cs | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs b/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs index 5f37763e530e..257cd742ab60 100644 --- a/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs +++ b/src/Controls/tests/Core.UnitTests/WebViewUnitTests.cs @@ -163,17 +163,17 @@ public void TestSettingOfCookie() Assert.NotNull(defaultWebView.Cookies); } - [Fact] - public void TestUrlWithNonWesternCharacters() + /// + /// This test validates that absolute URIs are not treated as relative ones. + /// Notably, we test URIs with non-Western characters (e.g., "Ğ" and spaces encoded as "%20"). + /// + [Theory] + [InlineData("https://example.com/test-Ağ-Sistem%20Bilgi%20Güvenliği%20Md/Guide.pdf")] + [InlineData("https://google.com/[]")] + public void TestUrisWithSpecialCharacters(string uri) { - // This test validates that URLs with non-Western characters (e.g., "Ğ" and spaces encoded as "%20") - // are correctly identified as absolute URLs and not treated as relative URLs. - - string finalUrl = "https://example.com/test-Ağ-Sistem%20Bilgi%20Güvenliği%20Md/Guide.pdf"; - - bool valid = WebViewHelper.IsRelativeUrl(finalUrl); - - Assert.False(valid, "The URL was identified as a relative URL"); + bool valid = WebViewHelper.IsRelativeUrl(uri); + Assert.False(valid, $"The URI '{uri}' was identified as a relative URI."); } } }