GNOME Bugzilla – Bug 677923
Add soup_cookie_jar_set_cookie_with_first_party() alternative that takes a SoupCookie in argument
Last modified: 2012-06-12 17:02:10 UTC
Currently, the only way to add a cookie while checking first_party is to use soup_cookie_jar_set_cookie_with_first_party(). However, this function takes an unparsed cookie in argument. In the event the client has already parsed the cookie (e.g. to do some pre-processing), it would be useful to have an alternative to soup_cookie_jar_set_cookie_with_first_party() which takes a parsed SoupCookie in argument. This would be more efficient. The alternative for the client would be to duplicate the policy check code and then call soup_cookie_jar_add_cookie(). However, duplicating the policy check code is not nice or maintainable. This new API function would be useful to WebKit [1]. [1] https://bugs.webkit.org/show_bug.cgi?id=88760
Created attachment 216172 [details] [review] Patch
Comment on attachment 216172 [details] [review] Patch as with the other patch, the new function needs to be added to the docs too >- if (!uri->host) >- return; you need to keep this check in soup_cookie_jar_add_cookie_with_first_party(), in particular so that webkit won't crash when adding a cookie from a file: URI.
Created attachment 216203 [details] [review] Patch Take the feedback into consideration, sorry I missed that.
Comment on attachment 216203 [details] [review] Patch no, you want the check in _add_cookie_, not _set_cookie_, so it gets checked in both cases. ok to commit with that change
Created attachment 216214 [details] [review] Patch I added the cookie->domain check in soup_cookie_jar_add_cookie_with_first_party(), hopefully this is what you meant. Note however that I kept the uri->host check in soup_cookie_jar_set_cookie_with_first_party(). Unless I'm mistaken, we still want it there because of the soup_cookie_parse() call. soup_cookie_parse() has a g_return_val_if_fail() check, not of an "if" check.
oh, whoops, my bad. The previous patch (attachment 216203 [details] [review] / git hash 668c6ceb) was correct. Please commit that.
Committed previous patch in: http://git.gnome.org/browse/libsoup/commit/?id=786cb47cd55fed9529b8defe009790b4d8471859 and bumped version to v2.39.2 in: http://git.gnome.org/browse/libsoup/commit/?id=a040294d6a8f9b59cda3bdd4611b0bf42fe21bdd