Lines Matching +full:no +full:- +full:useless +full:- +full:escape
4 HTTP::Cookies, from the libwww-perl library.
7 attributes of the HTTP cookie system as cookie-attributes, to distinguish
20 | ---MSIEBase | \
67 # There are a few catch-all except: statements in this module, for
78 # -----------------------------------------------------------------------------
101 The format of the returned string is like "YYYY-MM-DD hh:mm:ssZ",
104 1994-11-24 08:49:37Z
111 return "%04d-%02d-%02d %02d:%02d:%02dZ" % (
122 Wed, DD-Mon-YYYY HH:MM:SS GMT
129 return "%s, %02d-%s-%04d %02d:%02d:%02d GMT" % (
130 DAYS[dt.weekday()], dt.day, MONTHS[dt.month-1],
136 TIMEZONE_RE = re.compile(r"^([-+])?(\d\d?):?(\d\d)?$", re.ASCII)
147 if m.group(1) == '-':
148 offset = -offset
186 yr = yr + cur_yr - m
187 m = m - tmp
190 else: yr = yr - 100
192 # convert UTC time tuple to seconds since epoch (not timezone-adjusted)
203 t = t - offset
208 r"^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) "
211 r"^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*", re.I | re.ASCII)
215 (?:\s+|[-\/])
217 (?:\s+|[-\/])
226 ([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+) # timezone
240 string contains no timezone, UTC is assumed.
242 The timezone in the string may be numerical (like "-0800" or "+0100") or a
248 Wed, 09 Feb 1994 22:23:32 GMT -- HTTP format
249 Tuesday, 08-Feb-94 14:15:29 GMT -- old rfc850 HTTP format
250 Tuesday, 08-Feb-1994 14:15:29 GMT -- broken rfc850 HTTP format
251 09 Feb 1994 22:23:32 GMT -- HTTP format (no weekday)
252 08-Feb-94 14:15:29 GMT -- rfc850 format (no weekday)
253 08-Feb-1994 14:15:29 GMT -- broken rfc850 format (no weekday)
271 # No, we need some messy parsing...
275 text = WEEKDAY_RE.sub("", text, 1) # Useless weekday
292 [-\/]?
294 [-\/]?
297 (?:\s+|[-:Tt]) # separator before clock
303 ([-+]?\d\d?:?(:?\d\d)?
311 1994-02-03 14:15:29 -0100 -- ISO 8601 format
312 1994-02-03 14:15:29 -- zone is optional
313 1994-02-03 -- only date
314 1994-02-03T14:15:29 -- Use T as separator
315 19940203T141529Z -- ISO 8601 compact format
316 19940203 -- only date
338 # -----------------------------------------------------------------------------
372 quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
374 quoted-pair = "\" CHAR
378 value = token | quoted-string
388 >>> split_header_words(['text/html; charset="iso-8859-1"'])
389 [[('text/html', None), ('charset', 'iso-8859-1')]]
416 # no value, a lone token
441 >>> join_header_words([[("text/plain", None), ("charset", "iso-8859-1")]])
442 'text/plain; charset="iso-8859-1"'
443 >>> join_header_words([[("text/plain", None)], [("charset", "iso-8859-1")]])
444 'text/plain, charset="iso-8859-1"'
453 v = HEADER_JOIN_ESCAPE_RE.sub(r"\\\1", v) # escape " and \
464 text = text[:-1]
468 """Ad-hoc parser for Netscape protocol cookie-attributes.
470 The old Netscape cookie format for Set-Cookie can for instance contain
471 an unquoted "," in the expires field, so we have to use this ad-hoc
484 "version", "port", "max-age")
547 if text[0] == "." or text[-1] == ".":
552 """Return True if domain A domain-matches domain B, according to RFC 2965.
560 be case-insensitive.) Host A's name domain-matches host B's if
562 * their host name strings string-compare equal; or
564 * A is a HDN string and has the form NB, where N is a non-empty
566 x.y.com domain-matches .Y.com but not Y.com.)
568 Note that domain-match is not a commutative operation: a.b.c.com
569 domain-matches .c.com, but not the reverse.
573 # definition of the domain-match algorithm is the direct string-compare.
581 if i == -1 or i == 0:
591 """Return True if text is a sort-of-like a host domain name.
622 """Return request-host, as defined by RFC 2965.
638 """Return a tuple (request-host, effective request-host name).
644 if req_host.find(".") == -1 and not IPV4_RE.search(req_host):
649 """Path component of request-URI, as defined by RFC 2965."""
672 # Characters in addition to A-Z, a-z, 0-9, '_', '.', and '-' that don't
675 ESCAPED_CHAR_RE = re.compile(r"%([0-9a-fA-F][0-9a-fA-F])")
679 """Escape any invalid characters in HTTP URL, and uppercase all escapes."""
680 # There's no knowing what character encoding was used to create URLs
681 # containing %-escapes, but since we have to pick one to escape invalid
682 # path characters, we pick UTF-8, as recommended in the HTML 4.0
684 # http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.1
685 # And here, kind of: draft-fielding-uri-rfc2396bis-03
686 # (And in draft IRI specification: draft-duerst-iri-05)
699 - H is the host domain name of a host; and,
701 - H has the form A.B; and
703 - A has no embedded (that is, interior) dots; and
705 - B has at least one embedded dot, or B is the string "local".
732 An unverifiable transaction is to a third-party host if its request-
733 host U does not domain-match the reach R of the request-host O in the
752 objects -- it deals with cookie parsing, supplying defaults, and
789 # cookie-attribute had an initial dot, in order to follow RFC 2965
848 and RFC 2965 cookies -- override that if you want a customized policy.
854 Currently, pre-expired cookies never get this far -- the CookieJar
957 _debug(" - checking cookie %s=%s", cookie.name, cookie.value)
973 _debug(" Set-Cookie2 without version attribute (%s=%s)",
987 _debug(" third-party RFC 2965 cookie during "
991 _debug(" third-party Netscape cookie during "
1018 _debug(" domain %s is in user block-list", cookie.domain)
1021 _debug(" domain %s is not in user allow-list", cookie.domain)
1040 _debug(" country-code second level domain %s", domain)
1048 _debug(" non-local domain %s contains no embedded dot",
1055 _debug(" effective request-host %s (even with added "
1062 _debug(" effective request-host %s does not domain-match "
1067 host_prefix = req_host[:-len(domain)]
1105 _debug(" - checking cookie %s=%s", cookie.name, cookie.value)
1126 _debug(" third-party RFC 2965 cookie during unverifiable "
1130 _debug(" third-party Netscape cookie during unverifiable "
1137 _debug(" secure cookie with non-secure request")
1170 # strict check of non-domain cookies: Mozilla does this, MSIE5 doesn't
1174 _debug(" cookie with unspecified domain does not string-compare "
1179 _debug(" effective request-host name %s does not domain-match "
1183 _debug(" request-host %s does not match Netscape cookie domain "
1206 _debug(" domain %s is in user block-list", domain)
1209 _debug(" domain %s is not in user allow-list", domain)
1215 _debug("- checking cookie path=%s", path)
1224 _debug(" %s does not path-match %s", req_path, path)
1232 """Iterates over nested mapping, depth-first, in sorted order by key."""
1264 magic_re = re.compile(r"^\#LWP-Cookies-(\d+\.\d+)", re.ASCII)
1303 """Return a list of cookie-attributes to be returned to server.
1320 # What should it be if multiple matching Set-Cookie headers have
1322 # Answer: there is no answer; was supposed to be settled by
1332 # intact, due to the poorly-specified Netscape Cookie: syntax)
1339 # add cookie-attributes to be returned in Cookie header
1398 the Set-Cookie or Set-Cookie2 headers.
1402 cookie-attributes (discard, secure, version, expires or max-age,
1404 the cookie-attributes.
1411 "expires", "max-age",
1418 # Build dictionary of standard cookie-attributes (standard) and
1419 # dictionary of other cookie-attributes (rest).
1422 # cookies should have the Expires cookie-attribute, and V1 cookies
1423 # should have Max-Age, but since V1 includes RFC 2109 cookies (and
1424 # since V0 cookies may be a mish-mash of Netscape and RFC 2109), we
1425 # accept either (but prefer Max-Age).
1438 # boolean cookie-attribute is present, but has no value
1453 # Prefer max-age to expires (like Mozilla)
1459 if k == "max-age":
1464 _debug(" missing or invalid (non-numeric) value for "
1465 "max-age attribute")
1468 # convert RFC 2965 Max-Age to seconds since epoch
1470 # age-calculation rules. Remember that zero Max-Age
1492 # standard is dict of standard cookie-attributes, rest is dict of the
1522 if i != -1:
1546 # Port attr present, but has no value: default to request port.
1553 # No port attr present. Cookie can be sent back on any port.
1606 # get cookie-attributes for RFC 2965 and Netscape protocols
1608 rfc2965_hdrs = headers.get_all("Set-Cookie2", [])
1609 ns_hdrs = headers.get_all("Set-Cookie", [])
1619 return [] # no relevant cookie headers: quick exit
1638 # Look for Netscape cookies (from Set-Cookie headers) that match
1639 # corresponding RFC 2965 cookies (from Set-Cookie2 headers).
1706 Raises KeyError if no matching cookie exists.
1778 # derives from OSError for backwards-compatibility with Python 2.4.0
1839 Actually, the format is extended a bit -- see module docstring.
1866 The LWPCookieJar saves a sequence of "Set-Cookie3" lines.
1867 "Set-Cookie3" is the format used by the libwww-perl library, not known
1878 """Return cookies as a string of "\\n"-separated "Set-Cookie3" headers.
1890 r.append("Set-Cookie3: %s" % lwp_cookie_str(cookie))
1901 # port_spec) while still being compatible with libwww-perl, I hope.
1902 f.write("#LWP-Cookies-2.0\n")
1908 msg = ("%r does not look like a Set-Cookie3 (LWP) format "
1914 header = "Set-Cookie3:"
1980 raise LoadError("invalid Set-Cookie3 format file %r: %r" %
2005 specified by the Set-Cookie2 (or Set-Cookie) header, and whether or not the
2007 domains in Netscape files start with a dot and some don't -- trust me, you
2039 if line.endswith("\n"): line = line[:-1]
2051 # cookies.txt regards 'Set-Cookie: foo' as a cookie
2052 # with no name, whereas http.cookiejar regards it as a
2053 # cookie with no value.
2112 # cookies.txt regards 'Set-Cookie: foo' as a cookie
2113 # with no name, whereas http.cookiejar regards it as a
2114 # cookie with no value.