-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
HttpCookie.Value should return the URL decoded cookie value #394
Conversation
src/Microsoft.AspNetCore.SystemWebAdapters/Internal/HttpValueCollection.cs
Show resolved
Hide resolved
I manually tested these changes locally and confirmed that I'm not quite sure why this is happening or how the |
So it sounds like your fix gets us partially there, but there is still some URL encoding going on? If so, would you be up for integrating that method in? There's some e2e tests that set up a test host that should allow testing this scenario |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM - let me know if you want to merge this in or do the more extensive set-cookie fix
// convert existing string value into multivalue | ||
if (_stringValue != null) | ||
{ | ||
if (_stringValue.Contains('&', StringComparison.InvariantCulture) || _stringValue.Contains('=', StringComparison.InvariantCulture)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this what system.web was doing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@twsouthwick no, System.web is doing an .IndexOf
without the SystemComparison
argument. Do you want me to change it to IndexOf?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this is fine -I was wondering if the rest of it was something that system.web was doing
@twsouthwick Thanks for the review. I think I prefer to run some more e2e tests as this is not going to actually fix #393. Re e2e tests, are you referring to these Playwright tests here https://github.com/dotnet/systemweb-adapters/tree/main/test/Samples.MVCApp.Tests? |
@twsouthwick Updated the PR and added the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add the usings?
// convert existing string value into multivalue | ||
if (_stringValue != null) | ||
{ | ||
if (_stringValue.Contains('&', StringComparison.InvariantCulture) || _stringValue.Contains('=', StringComparison.InvariantCulture)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No this is fine -I was wondering if the rest of it was something that system.web was doing
[Fact] | ||
public async Task SetCookie() | ||
{ | ||
var result = await RunAsync(context => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: httpresponsemessage should have a using
; not sure why there's no analyzer catching that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@twsouthwick good catch. I just updated the PR and added using
. I can update the analyzer to catch this type of errors in a separate PR.
Overall, looks good, just a few nits |
@twsouthwick Just updated the tests and I think this PR is now ready to be merged. |
PR Title
HttpCookie.Value should return the URL decoded cookie value
PR Description
Create a new
HttpCookie
object in NET Standard / NET Core URL encodes the value of of cookie, whereas in NET Framework 4.7.2, this doesn't occur. This is probably the desired behavior but makes it difficult to share the same cookie between the two apps (NET Core and NET Framework).To reproduce this bug:
Also, here is an example that
HttpCookie
should just return the cookie value without URL encoding it: https://dotnetfiddle.net/eusU6N (butValues
should URL encode, which I added a unit test for it in this PR).Addresses #393