The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
From: Marty Alchin <gulop...@gmail.com>
Date: Thu, 24 Sep 2009 15:21:16 -0400
Local: Thurs, Sep 24 2009 3:21 pm
Subject: Re: Adding signing (and signed cookies) to Django core
On Thu, Sep 24, 2009 at 2:54 PM, Simon Willison <si...@simonwillison.net> wrote: The behavior you mention here is exactly what django-signedcookies > Hmm... I hadn't considered that. I was thinking that the unsigning > could be transparent, so by the time you access request.COOKIES['key'] > the value had already been unsigned (and if the signature failed the > cookie key just wouldn't be set at all, as if the cookie never > existed). But as you point out, this doesn't work because you can't > tell if the cookie was signed or not in the first place. does, but it can only do so because it can blindly assume that all cookies are signed, which as you pointed out, causes other problems. > We could fix this with a naming convention of some sort: That seems pretty ugly on the surface, but it does confine the > response.set_cookie('key', 'value', sign=True) ugliness to somewhere most people won't bother to look. One potential problem is if someone wants to use __Xsigned in the name of an unsigned cookie, but a namespace clash like that should be extremely rare in practice. Also, does the name of a cookie factor into the cookie length limits? > request.unsign_cookie('key') might be an option, as at least that I don't know if it's completely anti-ValueError, because a ValueError > reflects the set_cookie / sign / unsign API a bit. Not ideal by a long > shot though. >> try: >> value = signed.unsign(signed_value).decode('utf-8') >> except ValueError: >> # Whoops! UnicodeDecodeError winds up here as well! > That's a great argument against subclassing ValueError - I hadn't subclass does still make some sense semantically, and since you can catch more than one exception type in a try block, it's perfectly functional. It's just that when lazy people blindly catch ValueError without checking for something more specific as well, things can break. So it really just comes down to whether we expect people to be -Gul You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
| ||||||||||||||