{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/HttpAbstractions/issues/547","repository_url":"https://api.github.com/repos/aspnet/HttpAbstractions","labels_url":"https://api.github.com/repos/aspnet/HttpAbstractions/issues/547/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/HttpAbstractions/issues/547/comments","events_url":"https://api.github.com/repos/aspnet/HttpAbstractions/issues/547/events","html_url":"https://github.com/aspnet/HttpAbstractions/issues/547","id":129917851,"number":547,"title":"Continuation of encoding in Cookie discussion","user":{"login":"psibernetic","id":621605,"avatar_url":"https://avatars.githubusercontent.com/u/621605?v=3","gravatar_id":"","url":"https://api.github.com/users/psibernetic","html_url":"https://github.com/psibernetic","followers_url":"https://api.github.com/users/psibernetic/followers","following_url":"https://api.github.com/users/psibernetic/following{/other_user}","gists_url":"https://api.github.com/users/psibernetic/gists{/gist_id}","starred_url":"https://api.github.com/users/psibernetic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/psibernetic/subscriptions","organizations_url":"https://api.github.com/users/psibernetic/orgs","repos_url":"https://api.github.com/users/psibernetic/repos","events_url":"https://api.github.com/users/psibernetic/events{/privacy}","received_events_url":"https://api.github.com/users/psibernetic/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/HttpAbstractions/labels/0%20-%20Backlog","name":"0 - Backlog","color":"CCCCCC"},{"url":"https://api.github.com/repos/aspnet/HttpAbstractions/labels/bug","name":"bug","color":"fc2929"},{"url":"https://api.github.com/repos/aspnet/HttpAbstractions/labels/needs%20design","name":"needs design","color":"006b75"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-01-30T00:17:47Z","updated_at":"2016-02-15T21:44:54Z","closed_at":null,"body":"Refers to #535 & PR #546 \r\n\r\nAlso open on Katana: http://katanaproject.codeplex.com/workitem/442\r\n\r\n@Tratcher \r\n\r\nForcefully encoding and forcefully decoding breaks interoperability with existing solutions other than Microsoft.Owin. Furthermore cookie handling is now non-symmetrical in operations. Both the write and read use Uri.EscapeDataString, but the read operation does extra work which invalidates Base64. \r\n\r\n```csharp\r\npublic static RequestCookieCollection Parse(IList<string> values)\r\n        {\r\n            if (values.Count == 0)\r\n            {\r\n                return Empty;\r\n            }\r\n\r\n            IList<CookieHeaderValue> cookies;\r\n            if (CookieHeaderValue.TryParseList(values, out cookies))\r\n            {\r\n                if (cookies.Count == 0)\r\n                {\r\n                    return Empty;\r\n                }\r\n\r\n                var store = new Dictionary<string, string>(cookies.Count);\r\n                for (var i = 0; i < cookies.Count; i++)\r\n                {\r\n                    var cookie = cookies[i];\r\n                    var name = Uri.UnescapeDataString(cookie.Name.Replace('+', ' '));\r\n                    var value = Uri.UnescapeDataString(cookie.Value.Replace('+', ' '));\r\n                    store[name] = value;\r\n                }\r\n\r\n                return new RequestCookieCollection(store);\r\n            }\r\n            return Empty;\r\n        }\r\n```"},"comment":{"url":"https://api.github.com/repos/aspnet/HttpAbstractions/issues/comments/184408176","html_url":"https://github.com/aspnet/HttpAbstractions/issues/547#issuecomment-184408176","issue_url":"https://api.github.com/repos/aspnet/HttpAbstractions/issues/547","id":184408176,"user":{"login":"psibernetic","id":621605,"avatar_url":"https://avatars.githubusercontent.com/u/621605?v=3","gravatar_id":"","url":"https://api.github.com/users/psibernetic","html_url":"https://github.com/psibernetic","followers_url":"https://api.github.com/users/psibernetic/followers","following_url":"https://api.github.com/users/psibernetic/following{/other_user}","gists_url":"https://api.github.com/users/psibernetic/gists{/gist_id}","starred_url":"https://api.github.com/users/psibernetic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/psibernetic/subscriptions","organizations_url":"https://api.github.com/users/psibernetic/orgs","repos_url":"https://api.github.com/users/psibernetic/repos","events_url":"https://api.github.com/users/psibernetic/events{/privacy}","received_events_url":"https://api.github.com/users/psibernetic/received_events","type":"User","site_admin":false},"created_at":"2016-02-15T21:44:54Z","updated_at":"2016-02-15T21:44:54Z","body":"I have created a sample project using Katana to demonstrate the functionality that was ported over that is causing issues, it should adequately show the bug.\r\n\r\nThe example data I used was:\r\n```csharp\r\n//Had to come up with a string that would output a + in the encoded result\r\n// xml seems to do the trick.\r\nconst string Base64ExampleText = @\"<tag attribute=\"\"><childtag></tag>\";\r\n```\r\n\r\nRaw base64 output and what is in my cookie: \r\n```\r\nPHRhZyBhdHRyaWJ1dGU9Ij48Y2hpbGR0YWc+PC90YWc+\r\n```\r\n\r\nIOwinContext.Request.Cookies output: \r\n```\r\nPHRhZyBhdHRyaWJ1dGU9Ij48Y2hpbGR0YWc PC90YWc \r\n```\r\n\r\nWhich throws `Invalid length for a Base-64 char array or string.`\r\n\r\nhttps://github.com/psibernetic/KatanaCookieBase64IssueExample\r\n\r\nI haven't had time to use the ASPNET 5 implementation yet, but the code was ported over from Katana. \r\n\r\nAdditionally,\r\n`RequestCookieCollection` and `ResponseCookies` decode differently.\r\n\r\n\r\n@Tratcher \r\n\r\nThanks."}}