Edit File by line
/home/barbar84/www/wp-conte.../plugins/sujqvwi/AnonR/smanonr..../lib64/python3..../http
File: cookiejar.py
val = val.strip() if sep else None
[500] Fix | Delete
[501] Fix | Delete
if ii != 0:
[502] Fix | Delete
lc = key.lower()
[503] Fix | Delete
if lc in known_attrs:
[504] Fix | Delete
key = lc
[505] Fix | Delete
[506] Fix | Delete
if key == "version":
[507] Fix | Delete
# This is an RFC 2109 cookie.
[508] Fix | Delete
if val is not None:
[509] Fix | Delete
val = strip_quotes(val)
[510] Fix | Delete
version_set = True
[511] Fix | Delete
elif key == "expires":
[512] Fix | Delete
# convert expires date to seconds since epoch
[513] Fix | Delete
if val is not None:
[514] Fix | Delete
val = http2time(strip_quotes(val)) # None if invalid
[515] Fix | Delete
pairs.append((key, val))
[516] Fix | Delete
[517] Fix | Delete
if pairs:
[518] Fix | Delete
if not version_set:
[519] Fix | Delete
pairs.append(("version", "0"))
[520] Fix | Delete
result.append(pairs)
[521] Fix | Delete
[522] Fix | Delete
return result
[523] Fix | Delete
[524] Fix | Delete
[525] Fix | Delete
IPV4_RE = re.compile(r"\.\d+$", re.ASCII)
[526] Fix | Delete
def is_HDN(text):
[527] Fix | Delete
"""Return True if text is a host domain name."""
[528] Fix | Delete
# XXX
[529] Fix | Delete
# This may well be wrong. Which RFC is HDN defined in, if any (for
[530] Fix | Delete
# the purposes of RFC 2965)?
[531] Fix | Delete
# For the current implementation, what about IPv6? Remember to look
[532] Fix | Delete
# at other uses of IPV4_RE also, if change this.
[533] Fix | Delete
if IPV4_RE.search(text):
[534] Fix | Delete
return False
[535] Fix | Delete
if text == "":
[536] Fix | Delete
return False
[537] Fix | Delete
if text[0] == "." or text[-1] == ".":
[538] Fix | Delete
return False
[539] Fix | Delete
return True
[540] Fix | Delete
[541] Fix | Delete
def domain_match(A, B):
[542] Fix | Delete
"""Return True if domain A domain-matches domain B, according to RFC 2965.
[543] Fix | Delete
[544] Fix | Delete
A and B may be host domain names or IP addresses.
[545] Fix | Delete
[546] Fix | Delete
RFC 2965, section 1:
[547] Fix | Delete
[548] Fix | Delete
Host names can be specified either as an IP address or a HDN string.
[549] Fix | Delete
Sometimes we compare one host name with another. (Such comparisons SHALL
[550] Fix | Delete
be case-insensitive.) Host A's name domain-matches host B's if
[551] Fix | Delete
[552] Fix | Delete
* their host name strings string-compare equal; or
[553] Fix | Delete
[554] Fix | Delete
* A is a HDN string and has the form NB, where N is a non-empty
[555] Fix | Delete
name string, B has the form .B', and B' is a HDN string. (So,
[556] Fix | Delete
x.y.com domain-matches .Y.com but not Y.com.)
[557] Fix | Delete
[558] Fix | Delete
Note that domain-match is not a commutative operation: a.b.c.com
[559] Fix | Delete
domain-matches .c.com, but not the reverse.
[560] Fix | Delete
[561] Fix | Delete
"""
[562] Fix | Delete
# Note that, if A or B are IP addresses, the only relevant part of the
[563] Fix | Delete
# definition of the domain-match algorithm is the direct string-compare.
[564] Fix | Delete
A = A.lower()
[565] Fix | Delete
B = B.lower()
[566] Fix | Delete
if A == B:
[567] Fix | Delete
return True
[568] Fix | Delete
if not is_HDN(A):
[569] Fix | Delete
return False
[570] Fix | Delete
i = A.rfind(B)
[571] Fix | Delete
if i == -1 or i == 0:
[572] Fix | Delete
# A does not have form NB, or N is the empty string
[573] Fix | Delete
return False
[574] Fix | Delete
if not B.startswith("."):
[575] Fix | Delete
return False
[576] Fix | Delete
if not is_HDN(B[1:]):
[577] Fix | Delete
return False
[578] Fix | Delete
return True
[579] Fix | Delete
[580] Fix | Delete
def liberal_is_HDN(text):
[581] Fix | Delete
"""Return True if text is a sort-of-like a host domain name.
[582] Fix | Delete
[583] Fix | Delete
For accepting/blocking domains.
[584] Fix | Delete
[585] Fix | Delete
"""
[586] Fix | Delete
if IPV4_RE.search(text):
[587] Fix | Delete
return False
[588] Fix | Delete
return True
[589] Fix | Delete
[590] Fix | Delete
def user_domain_match(A, B):
[591] Fix | Delete
"""For blocking/accepting domains.
[592] Fix | Delete
[593] Fix | Delete
A and B may be host domain names or IP addresses.
[594] Fix | Delete
[595] Fix | Delete
"""
[596] Fix | Delete
A = A.lower()
[597] Fix | Delete
B = B.lower()
[598] Fix | Delete
if not (liberal_is_HDN(A) and liberal_is_HDN(B)):
[599] Fix | Delete
if A == B:
[600] Fix | Delete
# equal IP addresses
[601] Fix | Delete
return True
[602] Fix | Delete
return False
[603] Fix | Delete
initial_dot = B.startswith(".")
[604] Fix | Delete
if initial_dot and A.endswith(B):
[605] Fix | Delete
return True
[606] Fix | Delete
if not initial_dot and A == B:
[607] Fix | Delete
return True
[608] Fix | Delete
return False
[609] Fix | Delete
[610] Fix | Delete
cut_port_re = re.compile(r":\d+$", re.ASCII)
[611] Fix | Delete
def request_host(request):
[612] Fix | Delete
"""Return request-host, as defined by RFC 2965.
[613] Fix | Delete
[614] Fix | Delete
Variation from RFC: returned value is lowercased, for convenient
[615] Fix | Delete
comparison.
[616] Fix | Delete
[617] Fix | Delete
"""
[618] Fix | Delete
url = request.get_full_url()
[619] Fix | Delete
host = urllib.parse.urlparse(url)[1]
[620] Fix | Delete
if host == "":
[621] Fix | Delete
host = request.get_header("Host", "")
[622] Fix | Delete
[623] Fix | Delete
# remove port, if present
[624] Fix | Delete
host = cut_port_re.sub("", host, 1)
[625] Fix | Delete
return host.lower()
[626] Fix | Delete
[627] Fix | Delete
def eff_request_host(request):
[628] Fix | Delete
"""Return a tuple (request-host, effective request-host name).
[629] Fix | Delete
[630] Fix | Delete
As defined by RFC 2965, except both are lowercased.
[631] Fix | Delete
[632] Fix | Delete
"""
[633] Fix | Delete
erhn = req_host = request_host(request)
[634] Fix | Delete
if req_host.find(".") == -1 and not IPV4_RE.search(req_host):
[635] Fix | Delete
erhn = req_host + ".local"
[636] Fix | Delete
return req_host, erhn
[637] Fix | Delete
[638] Fix | Delete
def request_path(request):
[639] Fix | Delete
"""Path component of request-URI, as defined by RFC 2965."""
[640] Fix | Delete
url = request.get_full_url()
[641] Fix | Delete
parts = urllib.parse.urlsplit(url)
[642] Fix | Delete
path = escape_path(parts.path)
[643] Fix | Delete
if not path.startswith("/"):
[644] Fix | Delete
# fix bad RFC 2396 absoluteURI
[645] Fix | Delete
path = "/" + path
[646] Fix | Delete
return path
[647] Fix | Delete
[648] Fix | Delete
def request_port(request):
[649] Fix | Delete
host = request.host
[650] Fix | Delete
i = host.find(':')
[651] Fix | Delete
if i >= 0:
[652] Fix | Delete
port = host[i+1:]
[653] Fix | Delete
try:
[654] Fix | Delete
int(port)
[655] Fix | Delete
except ValueError:
[656] Fix | Delete
_debug("nonnumeric port: '%s'", port)
[657] Fix | Delete
return None
[658] Fix | Delete
else:
[659] Fix | Delete
port = DEFAULT_HTTP_PORT
[660] Fix | Delete
return port
[661] Fix | Delete
[662] Fix | Delete
# Characters in addition to A-Z, a-z, 0-9, '_', '.', and '-' that don't
[663] Fix | Delete
# need to be escaped to form a valid HTTP URL (RFCs 2396 and 1738).
[664] Fix | Delete
HTTP_PATH_SAFE = "%/;:@&=+$,!~*'()"
[665] Fix | Delete
ESCAPED_CHAR_RE = re.compile(r"%([0-9a-fA-F][0-9a-fA-F])")
[666] Fix | Delete
def uppercase_escaped_char(match):
[667] Fix | Delete
return "%%%s" % match.group(1).upper()
[668] Fix | Delete
def escape_path(path):
[669] Fix | Delete
"""Escape any invalid characters in HTTP URL, and uppercase all escapes."""
[670] Fix | Delete
# There's no knowing what character encoding was used to create URLs
[671] Fix | Delete
# containing %-escapes, but since we have to pick one to escape invalid
[672] Fix | Delete
# path characters, we pick UTF-8, as recommended in the HTML 4.0
[673] Fix | Delete
# specification:
[674] Fix | Delete
# http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.1
[675] Fix | Delete
# And here, kind of: draft-fielding-uri-rfc2396bis-03
[676] Fix | Delete
# (And in draft IRI specification: draft-duerst-iri-05)
[677] Fix | Delete
# (And here, for new URI schemes: RFC 2718)
[678] Fix | Delete
path = urllib.parse.quote(path, HTTP_PATH_SAFE)
[679] Fix | Delete
path = ESCAPED_CHAR_RE.sub(uppercase_escaped_char, path)
[680] Fix | Delete
return path
[681] Fix | Delete
[682] Fix | Delete
def reach(h):
[683] Fix | Delete
"""Return reach of host h, as defined by RFC 2965, section 1.
[684] Fix | Delete
[685] Fix | Delete
The reach R of a host name H is defined as follows:
[686] Fix | Delete
[687] Fix | Delete
* If
[688] Fix | Delete
[689] Fix | Delete
- H is the host domain name of a host; and,
[690] Fix | Delete
[691] Fix | Delete
- H has the form A.B; and
[692] Fix | Delete
[693] Fix | Delete
- A has no embedded (that is, interior) dots; and
[694] Fix | Delete
[695] Fix | Delete
- B has at least one embedded dot, or B is the string "local".
[696] Fix | Delete
then the reach of H is .B.
[697] Fix | Delete
[698] Fix | Delete
* Otherwise, the reach of H is H.
[699] Fix | Delete
[700] Fix | Delete
>>> reach("www.acme.com")
[701] Fix | Delete
'.acme.com'
[702] Fix | Delete
>>> reach("acme.com")
[703] Fix | Delete
'acme.com'
[704] Fix | Delete
>>> reach("acme.local")
[705] Fix | Delete
'.local'
[706] Fix | Delete
[707] Fix | Delete
"""
[708] Fix | Delete
i = h.find(".")
[709] Fix | Delete
if i >= 0:
[710] Fix | Delete
#a = h[:i] # this line is only here to show what a is
[711] Fix | Delete
b = h[i+1:]
[712] Fix | Delete
i = b.find(".")
[713] Fix | Delete
if is_HDN(h) and (i >= 0 or b == "local"):
[714] Fix | Delete
return "."+b
[715] Fix | Delete
return h
[716] Fix | Delete
[717] Fix | Delete
def is_third_party(request):
[718] Fix | Delete
"""
[719] Fix | Delete
[720] Fix | Delete
RFC 2965, section 3.3.6:
[721] Fix | Delete
[722] Fix | Delete
An unverifiable transaction is to a third-party host if its request-
[723] Fix | Delete
host U does not domain-match the reach R of the request-host O in the
[724] Fix | Delete
origin transaction.
[725] Fix | Delete
[726] Fix | Delete
"""
[727] Fix | Delete
req_host = request_host(request)
[728] Fix | Delete
if not domain_match(req_host, reach(request.origin_req_host)):
[729] Fix | Delete
return True
[730] Fix | Delete
else:
[731] Fix | Delete
return False
[732] Fix | Delete
[733] Fix | Delete
[734] Fix | Delete
class Cookie:
[735] Fix | Delete
"""HTTP Cookie.
[736] Fix | Delete
[737] Fix | Delete
This class represents both Netscape and RFC 2965 cookies.
[738] Fix | Delete
[739] Fix | Delete
This is deliberately a very simple class. It just holds attributes. It's
[740] Fix | Delete
possible to construct Cookie instances that don't comply with the cookie
[741] Fix | Delete
standards. CookieJar.make_cookies is the factory function for Cookie
[742] Fix | Delete
objects -- it deals with cookie parsing, supplying defaults, and
[743] Fix | Delete
normalising to the representation used in this class. CookiePolicy is
[744] Fix | Delete
responsible for checking them to see whether they should be accepted from
[745] Fix | Delete
and returned to the server.
[746] Fix | Delete
[747] Fix | Delete
Note that the port may be present in the headers, but unspecified ("Port"
[748] Fix | Delete
rather than"Port=80", for example); if this is the case, port is None.
[749] Fix | Delete
[750] Fix | Delete
"""
[751] Fix | Delete
[752] Fix | Delete
def __init__(self, version, name, value,
[753] Fix | Delete
port, port_specified,
[754] Fix | Delete
domain, domain_specified, domain_initial_dot,
[755] Fix | Delete
path, path_specified,
[756] Fix | Delete
secure,
[757] Fix | Delete
expires,
[758] Fix | Delete
discard,
[759] Fix | Delete
comment,
[760] Fix | Delete
comment_url,
[761] Fix | Delete
rest,
[762] Fix | Delete
rfc2109=False,
[763] Fix | Delete
):
[764] Fix | Delete
[765] Fix | Delete
if version is not None: version = int(version)
[766] Fix | Delete
if expires is not None: expires = int(float(expires))
[767] Fix | Delete
if port is None and port_specified is True:
[768] Fix | Delete
raise ValueError("if port is None, port_specified must be false")
[769] Fix | Delete
[770] Fix | Delete
self.version = version
[771] Fix | Delete
self.name = name
[772] Fix | Delete
self.value = value
[773] Fix | Delete
self.port = port
[774] Fix | Delete
self.port_specified = port_specified
[775] Fix | Delete
# normalise case, as per RFC 2965 section 3.3.3
[776] Fix | Delete
self.domain = domain.lower()
[777] Fix | Delete
self.domain_specified = domain_specified
[778] Fix | Delete
# Sigh. We need to know whether the domain given in the
[779] Fix | Delete
# cookie-attribute had an initial dot, in order to follow RFC 2965
[780] Fix | Delete
# (as clarified in draft errata). Needed for the returned $Domain
[781] Fix | Delete
# value.
[782] Fix | Delete
self.domain_initial_dot = domain_initial_dot
[783] Fix | Delete
self.path = path
[784] Fix | Delete
self.path_specified = path_specified
[785] Fix | Delete
self.secure = secure
[786] Fix | Delete
self.expires = expires
[787] Fix | Delete
self.discard = discard
[788] Fix | Delete
self.comment = comment
[789] Fix | Delete
self.comment_url = comment_url
[790] Fix | Delete
self.rfc2109 = rfc2109
[791] Fix | Delete
[792] Fix | Delete
self._rest = copy.copy(rest)
[793] Fix | Delete
[794] Fix | Delete
def has_nonstandard_attr(self, name):
[795] Fix | Delete
return name in self._rest
[796] Fix | Delete
def get_nonstandard_attr(self, name, default=None):
[797] Fix | Delete
return self._rest.get(name, default)
[798] Fix | Delete
def set_nonstandard_attr(self, name, value):
[799] Fix | Delete
self._rest[name] = value
[800] Fix | Delete
[801] Fix | Delete
def is_expired(self, now=None):
[802] Fix | Delete
if now is None: now = time.time()
[803] Fix | Delete
if (self.expires is not None) and (self.expires <= now):
[804] Fix | Delete
return True
[805] Fix | Delete
return False
[806] Fix | Delete
[807] Fix | Delete
def __str__(self):
[808] Fix | Delete
if self.port is None: p = ""
[809] Fix | Delete
else: p = ":"+self.port
[810] Fix | Delete
limit = self.domain + p + self.path
[811] Fix | Delete
if self.value is not None:
[812] Fix | Delete
namevalue = "%s=%s" % (self.name, self.value)
[813] Fix | Delete
else:
[814] Fix | Delete
namevalue = self.name
[815] Fix | Delete
return "<Cookie %s for %s>" % (namevalue, limit)
[816] Fix | Delete
[817] Fix | Delete
def __repr__(self):
[818] Fix | Delete
args = []
[819] Fix | Delete
for name in ("version", "name", "value",
[820] Fix | Delete
"port", "port_specified",
[821] Fix | Delete
"domain", "domain_specified", "domain_initial_dot",
[822] Fix | Delete
"path", "path_specified",
[823] Fix | Delete
"secure", "expires", "discard", "comment", "comment_url",
[824] Fix | Delete
):
[825] Fix | Delete
attr = getattr(self, name)
[826] Fix | Delete
args.append("%s=%s" % (name, repr(attr)))
[827] Fix | Delete
args.append("rest=%s" % repr(self._rest))
[828] Fix | Delete
args.append("rfc2109=%s" % repr(self.rfc2109))
[829] Fix | Delete
return "%s(%s)" % (self.__class__.__name__, ", ".join(args))
[830] Fix | Delete
[831] Fix | Delete
[832] Fix | Delete
class CookiePolicy:
[833] Fix | Delete
"""Defines which cookies get accepted from and returned to server.
[834] Fix | Delete
[835] Fix | Delete
May also modify cookies, though this is probably a bad idea.
[836] Fix | Delete
[837] Fix | Delete
The subclass DefaultCookiePolicy defines the standard rules for Netscape
[838] Fix | Delete
and RFC 2965 cookies -- override that if you want a customized policy.
[839] Fix | Delete
[840] Fix | Delete
"""
[841] Fix | Delete
def set_ok(self, cookie, request):
[842] Fix | Delete
"""Return true if (and only if) cookie should be accepted from server.
[843] Fix | Delete
[844] Fix | Delete
Currently, pre-expired cookies never get this far -- the CookieJar
[845] Fix | Delete
class deletes such cookies itself.
[846] Fix | Delete
[847] Fix | Delete
"""
[848] Fix | Delete
raise NotImplementedError()
[849] Fix | Delete
[850] Fix | Delete
def return_ok(self, cookie, request):
[851] Fix | Delete
"""Return true if (and only if) cookie should be returned to server."""
[852] Fix | Delete
raise NotImplementedError()
[853] Fix | Delete
[854] Fix | Delete
def domain_return_ok(self, domain, request):
[855] Fix | Delete
"""Return false if cookies should not be returned, given cookie domain.
[856] Fix | Delete
"""
[857] Fix | Delete
return True
[858] Fix | Delete
[859] Fix | Delete
def path_return_ok(self, path, request):
[860] Fix | Delete
"""Return false if cookies should not be returned, given cookie path.
[861] Fix | Delete
"""
[862] Fix | Delete
return True
[863] Fix | Delete
[864] Fix | Delete
[865] Fix | Delete
class DefaultCookiePolicy(CookiePolicy):
[866] Fix | Delete
"""Implements the standard rules for accepting and returning cookies."""
[867] Fix | Delete
[868] Fix | Delete
DomainStrictNoDots = 1
[869] Fix | Delete
DomainStrictNonDomain = 2
[870] Fix | Delete
DomainRFC2965Match = 4
[871] Fix | Delete
[872] Fix | Delete
DomainLiberal = 0
[873] Fix | Delete
DomainStrict = DomainStrictNoDots|DomainStrictNonDomain
[874] Fix | Delete
[875] Fix | Delete
def __init__(self,
[876] Fix | Delete
blocked_domains=None, allowed_domains=None,
[877] Fix | Delete
netscape=True, rfc2965=False,
[878] Fix | Delete
rfc2109_as_netscape=None,
[879] Fix | Delete
hide_cookie2=False,
[880] Fix | Delete
strict_domain=False,
[881] Fix | Delete
strict_rfc2965_unverifiable=True,
[882] Fix | Delete
strict_ns_unverifiable=False,
[883] Fix | Delete
strict_ns_domain=DomainLiberal,
[884] Fix | Delete
strict_ns_set_initial_dollar=False,
[885] Fix | Delete
strict_ns_set_path=False,
[886] Fix | Delete
secure_protocols=("https", "wss")
[887] Fix | Delete
):
[888] Fix | Delete
"""Constructor arguments should be passed as keyword arguments only."""
[889] Fix | Delete
self.netscape = netscape
[890] Fix | Delete
self.rfc2965 = rfc2965
[891] Fix | Delete
self.rfc2109_as_netscape = rfc2109_as_netscape
[892] Fix | Delete
self.hide_cookie2 = hide_cookie2
[893] Fix | Delete
self.strict_domain = strict_domain
[894] Fix | Delete
self.strict_rfc2965_unverifiable = strict_rfc2965_unverifiable
[895] Fix | Delete
self.strict_ns_unverifiable = strict_ns_unverifiable
[896] Fix | Delete
self.strict_ns_domain = strict_ns_domain
[897] Fix | Delete
self.strict_ns_set_initial_dollar = strict_ns_set_initial_dollar
[898] Fix | Delete
self.strict_ns_set_path = strict_ns_set_path
[899] Fix | Delete
self.secure_protocols = secure_protocols
[900] Fix | Delete
[901] Fix | Delete
if blocked_domains is not None:
[902] Fix | Delete
self._blocked_domains = tuple(blocked_domains)
[903] Fix | Delete
else:
[904] Fix | Delete
self._blocked_domains = ()
[905] Fix | Delete
[906] Fix | Delete
if allowed_domains is not None:
[907] Fix | Delete
allowed_domains = tuple(allowed_domains)
[908] Fix | Delete
self._allowed_domains = allowed_domains
[909] Fix | Delete
[910] Fix | Delete
def blocked_domains(self):
[911] Fix | Delete
"""Return the sequence of blocked domains (as a tuple)."""
[912] Fix | Delete
return self._blocked_domains
[913] Fix | Delete
def set_blocked_domains(self, blocked_domains):
[914] Fix | Delete
"""Set the sequence of blocked domains."""
[915] Fix | Delete
self._blocked_domains = tuple(blocked_domains)
[916] Fix | Delete
[917] Fix | Delete
def is_blocked(self, domain):
[918] Fix | Delete
for blocked_domain in self._blocked_domains:
[919] Fix | Delete
if user_domain_match(domain, blocked_domain):
[920] Fix | Delete
return True
[921] Fix | Delete
return False
[922] Fix | Delete
[923] Fix | Delete
def allowed_domains(self):
[924] Fix | Delete
"""Return None, or the sequence of allowed domains (as a tuple)."""
[925] Fix | Delete
return self._allowed_domains
[926] Fix | Delete
def set_allowed_domains(self, allowed_domains):
[927] Fix | Delete
"""Set the sequence of allowed domains, or None."""
[928] Fix | Delete
if allowed_domains is not None:
[929] Fix | Delete
allowed_domains = tuple(allowed_domains)
[930] Fix | Delete
self._allowed_domains = allowed_domains
[931] Fix | Delete
[932] Fix | Delete
def is_not_allowed(self, domain):
[933] Fix | Delete
if self._allowed_domains is None:
[934] Fix | Delete
return False
[935] Fix | Delete
for allowed_domain in self._allowed_domains:
[936] Fix | Delete
if user_domain_match(domain, allowed_domain):
[937] Fix | Delete
return False
[938] Fix | Delete
return True
[939] Fix | Delete
[940] Fix | Delete
def set_ok(self, cookie, request):
[941] Fix | Delete
"""
[942] Fix | Delete
If you override .set_ok(), be sure to call this method. If it returns
[943] Fix | Delete
false, so should your subclass (assuming your subclass wants to be more
[944] Fix | Delete
strict about which cookies to accept).
[945] Fix | Delete
[946] Fix | Delete
"""
[947] Fix | Delete
_debug(" - checking cookie %s=%s", cookie.name, cookie.value)
[948] Fix | Delete
[949] Fix | Delete
assert cookie.name is not None
[950] Fix | Delete
[951] Fix | Delete
for n in "version", "verifiability", "name", "path", "domain", "port":
[952] Fix | Delete
fn_name = "set_ok_"+n
[953] Fix | Delete
fn = getattr(self, fn_name)
[954] Fix | Delete
if not fn(cookie, request):
[955] Fix | Delete
return False
[956] Fix | Delete
[957] Fix | Delete
return True
[958] Fix | Delete
[959] Fix | Delete
def set_ok_version(self, cookie, request):
[960] Fix | Delete
if cookie.version is None:
[961] Fix | Delete
# Version is always set to 0 by parse_ns_headers if it's a Netscape
[962] Fix | Delete
# cookie, so this must be an invalid RFC 2965 cookie.
[963] Fix | Delete
_debug(" Set-Cookie2 without version attribute (%s=%s)",
[964] Fix | Delete
cookie.name, cookie.value)
[965] Fix | Delete
return False
[966] Fix | Delete
if cookie.version > 0 and not self.rfc2965:
[967] Fix | Delete
_debug(" RFC 2965 cookies are switched off")
[968] Fix | Delete
return False
[969] Fix | Delete
elif cookie.version == 0 and not self.netscape:
[970] Fix | Delete
_debug(" Netscape cookies are switched off")
[971] Fix | Delete
return False
[972] Fix | Delete
return True
[973] Fix | Delete
[974] Fix | Delete
def set_ok_verifiability(self, cookie, request):
[975] Fix | Delete
if request.unverifiable and is_third_party(request):
[976] Fix | Delete
if cookie.version > 0 and self.strict_rfc2965_unverifiable:
[977] Fix | Delete
_debug(" third-party RFC 2965 cookie during "
[978] Fix | Delete
"unverifiable transaction")
[979] Fix | Delete
return False
[980] Fix | Delete
elif cookie.version == 0 and self.strict_ns_unverifiable:
[981] Fix | Delete
_debug(" third-party Netscape cookie during "
[982] Fix | Delete
"unverifiable transaction")
[983] Fix | Delete
return False
[984] Fix | Delete
return True
[985] Fix | Delete
[986] Fix | Delete
def set_ok_name(self, cookie, request):
[987] Fix | Delete
# Try and stop servers setting V0 cookies designed to hack other
[988] Fix | Delete
# servers that know both V0 and V1 protocols.
[989] Fix | Delete
if (cookie.version == 0 and self.strict_ns_set_initial_dollar and
[990] Fix | Delete
cookie.name.startswith("$")):
[991] Fix | Delete
_debug(" illegal name (starts with '$'): '%s'", cookie.name)
[992] Fix | Delete
return False
[993] Fix | Delete
return True
[994] Fix | Delete
[995] Fix | Delete
def set_ok_path(self, cookie, request):
[996] Fix | Delete
if cookie.path_specified:
[997] Fix | Delete
req_path = request_path(request)
[998] Fix | Delete
if ((cookie.version > 0 or
[999] Fix | Delete
It is recommended that you Edit text format, this type of Fix handles quite a lot in one request
Function