Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/client/Microsoft.Identity.Client/Utils/CoreHelpers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ public static string UrlEncode(string message)
}

message = Uri.EscapeDataString(message);
message = message.Replace("%20", "+");

return message;
}
Expand All @@ -44,7 +43,7 @@ public static string UrlDecode(string message)
{
return message;
}

// Keep trying to replace "+" to "%20" to increase compatibility
message = message.Replace("+", "%20");
message = Uri.UnescapeDataString(message);

Expand Down
26 changes: 26 additions & 0 deletions tests/Microsoft.Identity.Test.Unit/CoreTests/CoreHelperTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

using Microsoft.Identity.Client;
using Microsoft.Identity.Test.Common.Core.Helpers;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Identity.Client.Internal;
using Microsoft.Identity.Client.Utils;

namespace Microsoft.Identity.Test.Unit.CoreTests
{
[TestClass]
public class CoreHelperTests
{
[TestMethod]
public void UrlEncodeDecodeTest()
{
Assert.AreEqual(CoreHelpers.UrlEncode("https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize"), "https%3A%2F%2Flogin.microsoftonline.com%2Forganizations%2Foauth2%2Fv2.0%2Fauthorize");
Assert.AreEqual(CoreHelpers.UrlEncode("https://management.core.windows.net//.default openid profile offline_access"), "https%3A%2F%2Fmanagement.core.windows.net%2F%2F.default%20openid%20profile%20offline_access");

Assert.AreEqual(CoreHelpers.UrlDecode("https%3A%2F%2Flogin.microsoftonline.com%2Forganizations%2Foauth2%2Fv2.0%2Fauthorize"), "https://login.microsoftonline.com/organizations/oauth2/v2.0/authorize");
Assert.AreEqual(CoreHelpers.UrlDecode("https%3A%2F%2Fmanagement.core.windows.net%2F%2F.default%20openid%20profile%20offline_access"), "https://management.core.windows.net//.default openid profile offline_access");
Assert.AreEqual(CoreHelpers.UrlDecode("https%3A%2F%2Fmanagement.core.windows.net%2F%2F.default+openid+profile+offline_access"), "https://management.core.windows.net//.default openid profile offline_access");
}
}
}
Loading