String encoding in cookies make them be rejected by PHP

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

String encoding in cookies make them be rejected by PHP

Gloria W

Hi again,

I currently have a problem with cookies created by cherrypy. Looks like
any string value stored in a cherrypy cookie is "encoded" with double
quotes as part of the cookie value.
Example:

(Pdb) p cookie['cookie_email'].__dict__
{'coded_value': '"[hidden email]"', 'value': '[hidden email]', 'key':
'cookie_email'}

The coded vale seems the be the one I find in the cookie.

I am wedging cherrypy code between old PHP pieces, so the cookies have
to be compatible between PHP and cherrypy, or I am up the creek.

My PHP system sees the cookie like this:

ARGH! Bad email passed: \"[hidden email]\"

How do I ask cherrypy to stop encoding my cookie string value, so PHP
will accept it?

many thank yous in advance,
Gloria


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: String encoding in cookies make them be rejected by PHP

Gloria W

Well, I managed to work around this problem by changing the PHP, so
that it converts the cookie to what it needs to see.

But, I still want to know how to control cookie encoding in CherryPy.

Can someone point me to a doc? It's not easily found through a web
search.

Thank you,
Gloria


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply | Threaded
Open this post in threaded view
|

Re: String encoding in cookies make them be rejected by PHP

Robert Brewer

Gloria wrote:
> Well, I managed to work around this problem by changing the PHP, so
> that it converts the cookie to what it needs to see.
>
> But, I still want to know how to control cookie encoding in CherryPy.
>
> Can someone point me to a doc? It's not easily found through a web
> search.

I found the source code for Cookie.py illuminating:

# These quoting routines conform to the RFC2109 specification, which in
# turn references the character definitions from RFC2068.  They provide
# a two-way quoting algorithm.  Any non-text character is translated
# into a 4 character sequence: a forward-slash followed by the
# three-digit octal equivalent of the character.  Any '\' or '"' is
# quoted with a preceeding '\' slash.
#
# These are taken from RFC2068 and RFC2109.
#       _LegalChars       is the list of chars which don't require "'s
#       _Translator       hash-table for fast quoting
#
_LegalChars       = string.ascii_letters + string.digits +
"!#$%&'*+-.^_`|~"


...so it seems you could extend the set of legal characters (and
thereby avoid quoting) if you really needed to. But from a cursory
glance, it looks like the Cookie module gets it right (according to the
spec), and you should look at PHP's cookie-handling to see if it even
mentions quoting concerns.


Robert Brewer
System Architect
Amor Ministries
[hidden email]


--~--~---------~--~----~------------~-------~--~----~
 You received this message because you are subscribed to the Google Groups "cherrypy-users" group.
To post to this group, send email to [hidden email]
To unsubscribe from this group, send email to [hidden email]
For more options, visit this group at http://groups-beta.google.com/group/cherrypy-users?hl=en
-~----------~----~----~----~------~----~------~--~---