Skip to content
This repository has been archived by the owner on Jan 24, 2021. It is now read-only.

Automatically decode cookie values in Cookies dictionary #1390

Merged
merged 13 commits into from
Oct 28, 2015
Merged

Automatically decode cookie values in Cookies dictionary #1390

merged 13 commits into from
Oct 28, 2015

Conversation

richardprice
Copy link
Contributor

A new test to check if the cookie value is correctly decoded on reading
from Request.Cookies and a fix for the existing issue the test
highlights.

A new test to check if the cookie value is correctly decoded on reading
from Request.Cookies and a fix for the existing issue the test
highlights.
[Fact]
public void Cookie_should_decode_value_correctly()
{
// When
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you make it Given & When

Broke out cookie test module into its own file and rewrote test into
Given When format.
@thecodejunkie
Copy link
Member

@richardprice Travis does not like this one. Tell me something's gone boo-boo

Nancy.Testing.Tests.BrowserFixture.Should_maintain_cookies_even_if_not_set_on_directly_preceding_request [FAIL]
   Assert.Equal() Failure
   Position: First difference is at position 26
   Expected: Current session value is: I've created a session!
   Actual:   Current session value is:

@thecodejunkie
Copy link
Member

Still had failing tests when I ran it locally. Moved this to 0.23 because maybe we need to remake so that the cookie behavior is consistent between Request (IDictionary<string, string>) and Response (IList<INancyCookie>)

Thanks VS2012 for hiding these on Friday, for whatever reason you chose
to.
@richardprice
Copy link
Contributor Author

Do you want me to go ahead and start on the normalisation between Request and Response cookie handling?

@thecodejunkie
Copy link
Member

@richardprice I think we need to discuss this first. Will talk to @grumpydev when the dust of the 0.22 release has settled

@thecodejunkie thecodejunkie modified the milestones: 0.24, 0.23 Mar 16, 2014
@@ -177,7 +177,8 @@ public string Path
}
}

cookieDictionary[cookieName] = parts[1];
cookieDictionary[cookieName] = Helpers.HttpUtility.UrlDecode(parts[1]);
//cookieDictionary[cookieName] = parts[1];
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commented out code? :)

@grumpydev grumpydev modified the milestones: Future, 0.24 Jun 10, 2014
@khellang khellang removed this from the Future milestone Aug 19, 2015
@thecodejunkie thecodejunkie added this to the 1.4 milestone Aug 22, 2015
@thecodejunkie
Copy link
Member

Moving this to 1.4 milestone. @richardprice could you rebase so we have a running version to discuss on? Thanks ❤️

@jchannon
Copy link
Member

ping @richardprice

@richardprice
Copy link
Contributor Author

Sorry, missed this first time round, will sort soon.

On 24 September 2015 at 14:46, Jonathan Channon [email protected]
wrote:

ping @richardprice https://github.com/richardprice


Reply to this email directly or view it on GitHub
#1390 (comment).

The most exciting phrase to hear in science, the one that heralds new
discoveries, is not 'Eureka!' but 'That's funny...' - Isaac Asimov

@thecodejunkie thecodejunkie modified the milestone: 1.4 Oct 23, 2015
A new test to check if the cookie value is correctly decoded on reading
from Request.Cookies and a fix for the existing issue the test
highlights.
Broke out cookie test module into its own file and rewrote test into
Given When format.
Thanks VS2012 for hiding these on Friday, for whatever reason you chose
to.
…Spike

Conflicts:
	src/Nancy.Hosting.Wcf.Tests/NancyWcfGenericServiceFixture.cs
	src/Nancy.sln.DotSettings
	src/Nancy/Request.cs
	src/Nancy/Session/CookieBasedSessions.cs
@khellang
Copy link
Member

This is good to go now?

@richardprice
Copy link
Contributor Author

Yup.

On 28 October 2015 at 19:50, Kristian Hellang [email protected]
wrote:

This is good to go now?


Reply to this email directly or view it on GitHub
#1390 (comment).

The most exciting phrase to hear in science, the one that heralds new
discoveries, is not 'Eureka!' but 'That's funny...' - Isaac Asimov

using Testing;
using Xunit;

public class CookieTestsFixture
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@richardprice Can you either 1) rename the class, or 2) rename the file? 😄 And maybe not include both "tests" and "fixture"?

khellang added a commit that referenced this pull request Oct 28, 2015
Added test and fix for cookie decoding issue
@khellang khellang merged commit c101d7b into NancyFx:master Oct 28, 2015
@khellang
Copy link
Member

❤️ Sorry it took almost 2 years 😝

@khellang khellang changed the title Added test and fix for cookie decoding issue Automatically decode cookie values in Cookies dictionary Oct 30, 2015
@khellang
Copy link
Member

This is a breaking change.

If you manually decode cookies from the Request.Cookies dictionary, you should remove the decoding:

- var cookie = HttpUtility.UrlDecode(request.Cookies[cookieName]);
+ var cookie = request.Cookies[cookieName];

fxbit pushed a commit to yodiwo/Nancy that referenced this pull request Aug 19, 2016
Added test and fix for cookie decoding issue
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants