This repository has been archived by the owner on Nov 20, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#547 Remove '+' replacement from request cookies.
- Loading branch information
Showing
3 changed files
with
49 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
test/Microsoft.AspNetCore.Http.Tests/RequestCookiesCollectionTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// Copyright (c) .NET Foundation. All rights reserved. | ||
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. | ||
|
||
using System.Linq; | ||
using Microsoft.AspNetCore.Http.Internal; | ||
using Microsoft.Extensions.Primitives; | ||
using Xunit; | ||
|
||
namespace Microsoft.AspNetCore.Http.Tests | ||
{ | ||
public class RequestCookiesCollectionTests | ||
{ | ||
public static TheoryData UnEscapesKeyValues_Data | ||
{ | ||
get | ||
{ | ||
// key, value, expected | ||
return new TheoryData<string, string, string> | ||
{ | ||
{ "key=value", "key", "value" }, | ||
{ "key%2C=%21value", "key,", "!value" }, | ||
{ "ke%23y%2C=val%5Eue", "ke#y,", "val^ue" }, | ||
{ "key=value", "key", "value" }, | ||
{ "key%2C=%21value", "key,", "!value" }, | ||
{ "ke%23y%2C=val%5Eue", "ke#y,", "val^ue" }, | ||
{ "base64=QUI%2BREU%2FRw%3D%3D", "base64", "QUI+REU/Rw==" }, | ||
{ "base64=QUI+REU/Rw==", "base64", "QUI+REU/Rw==" }, | ||
}; | ||
} | ||
} | ||
|
||
[Theory] | ||
[MemberData(nameof(UnEscapesKeyValues_Data))] | ||
public void UnEscapesKeyValues( | ||
string input, | ||
string expectedKey, | ||
string expectedValue) | ||
{ | ||
var cookies = RequestCookieCollection.Parse(new StringValues(input)); | ||
|
||
Assert.Equal(1, cookies.Count); | ||
Assert.Equal(expectedKey, cookies.Keys.Single()); | ||
Assert.Equal(expectedValue, cookies[expectedKey]); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters