Https scheme fix, merging #12790 (#13606)

* HTTPS by default, HTTP only if specified

* Added/Updated unit tests;Added FTPS

* Added confirmation to system messages such as shutdown, reboot, and lock

* Corrected Typo

* Added confirmation to system messages such as shutdown, reboot, and lock

* Corrected Typo

* Made changes requested by @mykhailopylyp

* Further changes per review by mykhailopylyp

* Fixes per code review

* Changes per Mykhailopylyp

* Fix all schemes being replaced with HTTPS

Added new tests

* Merging conflicts

* Add ftp to fix spell-check

* Fix unit tests

Co-authored-by: chrisharris333 <60838650+chrisharris333@users.noreply.github.com>
Co-authored-by: Chris Harris <chris.harris@mytinycloud.com>
This commit is contained in:
Franky Chen
2021-10-05 01:56:27 +08:00
committed by GitHub
parent 9d3c5e50d6
commit 7daf35d898
4 changed files with 17 additions and 3 deletions

View File

@@ -669,6 +669,7 @@ FRAMEDOWNLOAD
franky franky
Froml Froml
fstream fstream
ftp
ftps ftps
FTYPE FTYPE
FULLNAME FULLNAME

View File

@@ -52,6 +52,10 @@ namespace Microsoft.Plugin.Uri.UnitTests.UriHelper
[DataRow("http://[2001:0DB8::1]", true, "http://[2001:db8::1]/")] [DataRow("http://[2001:0DB8::1]", true, "http://[2001:db8::1]/")]
[DataRow("[2001:0DB8::1]:80", true, "https://[2001:db8::1]/")] [DataRow("[2001:0DB8::1]:80", true, "https://[2001:db8::1]/")]
[DataRow("http://[2001:0DB8::1]:80", true, "http://[2001:db8::1]/")] [DataRow("http://[2001:0DB8::1]:80", true, "http://[2001:db8::1]/")]
[DataRow("mailto:example@mail.com", true, "mailto:example@mail.com")]
[DataRow("tel:411", true, "tel:411")]
[DataRow("ftp://example.com", true, "ftp://example.com/")]
public void TryParseCanParseHostName(string query, bool expectedSuccess, string expectedResult) public void TryParseCanParseHostName(string query, bool expectedSuccess, string expectedResult)
{ {
// Arrange // Arrange

View File

@@ -35,8 +35,17 @@ namespace Microsoft.Plugin.Uri.UriHelper
var hadDefaultPort = urlBuilder.Uri.IsDefaultPort; var hadDefaultPort = urlBuilder.Uri.IsDefaultPort;
urlBuilder.Port = hadDefaultPort ? -1 : urlBuilder.Port; urlBuilder.Port = hadDefaultPort ? -1 : urlBuilder.Port;
if (!input.Contains("HTTP://", StringComparison.OrdinalIgnoreCase) && if (input.Contains("HTTP://", StringComparison.OrdinalIgnoreCase))
!input.Contains("FTPS://", StringComparison.OrdinalIgnoreCase)) {
urlBuilder.Scheme = System.Uri.UriSchemeHttp;
}
else if (input.Contains(":", StringComparison.OrdinalIgnoreCase) &&
!input.Contains("http", StringComparison.OrdinalIgnoreCase) &&
!input.Contains("[", StringComparison.OrdinalIgnoreCase))
{
// Do nothing, leave unchanged
}
else
{ {
urlBuilder.Scheme = System.Uri.UriSchemeHttps; urlBuilder.Scheme = System.Uri.UriSchemeHttps;
} }

View File

@@ -1,4 +1,4 @@
// Copyright (c) Microsoft Corporation // Copyright (c) Microsoft Corporation
// The Microsoft Corporation licenses this file to you under the MIT license. // The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information. // See the LICENSE file in the project root for more information.