-
Notifications
You must be signed in to change notification settings - Fork 566
= http: introduce parsing rules for invalid cookies #925
base: master
Are you sure you want to change the base?
Conversation
spray#737 This approach will skip invalid cookies, but does not change the API surface. In particular, there is no RawHeader for the invalid cookies.
spray#737 The parsing is expected to throw out cookie pairs that pass the permissive syntax but not the strict syntax. Any cookies that pass the strict syntax should be returned.
Thanks for this PR! |
3629cf4
to
f8a4131
Compare
…ookies Conflicts: spray-http/src/main/scala/spray/http/parser/CookieHeaders.scala
Due to spray#869, a comma is a valid separator, and so everything after the first comma in a cookie's value (there shouldn't be commas in the cookie value, but a user agent is required to be tolerant of them according to RFC6265) is silently discarded. This isn't a breaking change because without this fix, any cookie containing a comma in the value would result in *all* the cookies being discarded (albeit with a log message, which now will not appear). Correct behaviour would require not allowing commas as a separator.
PR updated to fix merge conflict from #869. Note the behaviour (documented in commit notes and as a test) resulting from having commas in cookie values. Commas in cookie values are technically illegal according to the grammar, yet RFC6265 requires user agents to handle them and send them back as is (more notes on comma handling in cookies). As mentioned in the commit notes, Spray currently handles a bad cookie of the form Anyway, this is ready to be merged; it's still a big improvement over the current state of "bad cookie" handling. |
Thanks again for this PR, @ajknoll and @caspark! I think this is a nice fix, which we'll definitely want to merge and port to Akka HTTP. |
I'd like to know if the concern I voiced in #737 about
is tested and addressed in this PR. I think we also need more test coverage, discussion, and documentation what exactly to expect in the erroneous or ambiguous cases like the one reported in #869 and #702. |
@jrudolph re your voiced concern, I don't think this introduces any further ambiguity. There are tests added by this PR which demonstrate what happens when:
We're happy to add any extra tests you'd like to see (@ajknoll has already offered extra property-based tests in his initial comment), discuss with other people (if you tell us who you want this discussed with), and/or update documentation (if you give us a pointer to the file(s) to update). |
@caspark thanks for giving your opinions and your contribution. Adding no further ambiguity is certainly good. :) I agree that we need to make a decision about how to proceed. I think we need to collect all cases that we have seen up to now and need to make sure we find a solution we can keep and improve on for a while. |
resolves #737
This fix introduces the ability to parse cookies headers with some valid and some invalid cookie pairs. This will allow Spray to gracefully handle (by discarding) cookies hanging around from the old Netscape style (see http://curl.haxx.se/rfc/cookie_spec.html), while still only constructing
HttpCookie
s from RFC-valid cookies.I've made this fix using the testing style found in the existing
HttpHeaderSpec
. However, I believe more comprehensive test coverage can be accomplished, and I've put together an example in atlassian@4a376f4 ; if that looks acceptable, please let me know and I'll open a PR from the branch with those tests instead :)