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 | \
59 # There are a few catch-all except: statements in this module, for
70 # -----------------------------------------------------------------------------
93 The format of the returned string is like "YYYY-MM-DD hh:mm:ssZ",
96 1994-11-24 08:49:37Z
103 return "%04d-%02d-%02d %02d:%02d:%02dZ" % (
114 Wed, DD-Mon-YYYY HH:MM:SS GMT
121 return "%s, %02d-%s-%04d %02d:%02d:%02d GMT" % (
122 DAYS[dt.weekday()], dt.day, MONTHS[dt.month-1],
128 TIMEZONE_RE = re.compile(r"^([-+])?(\d\d?):?(\d\d)?$", re.ASCII)
139 if m.group(1) == '-':
140 offset = -offset
178 yr = yr + cur_yr - m
179 m = m - tmp
182 else: yr = yr - 100
184 # convert UTC time tuple to seconds since epoch (not timezone-adjusted)
195 t = t - offset
200 r"^[SMTWF][a-z][a-z], (\d\d) ([JFMASOND][a-z][a-z]) "
203 r"^(?:Sun|Mon|Tue|Wed|Thu|Fri|Sat)[a-z]*,?\s*", re.I | re.ASCII)
207 (?:\s+|[-\/])
209 (?:\s+|[-\/])
218 ([-+]?\d{2,4}|(?![APap][Mm]\b)[A-Za-z]+) # timezone
232 string contains no timezone, UTC is assumed.
234 The timezone in the string may be numerical (like "-0800" or "+0100") or a
240 Wed, 09 Feb 1994 22:23:32 GMT -- HTTP format
241 Tuesday, 08-Feb-94 14:15:29 GMT -- old rfc850 HTTP format
242 Tuesday, 08-Feb-1994 14:15:29 GMT -- broken rfc850 HTTP format
243 09 Feb 1994 22:23:32 GMT -- HTTP format (no weekday)
244 08-Feb-94 14:15:29 GMT -- rfc850 format (no weekday)
245 08-Feb-1994 14:15:29 GMT -- broken rfc850 format (no weekday)
263 # No, we need some messy parsing...
267 text = WEEKDAY_RE.sub("", text, 1) # Useless weekday
284 [-\/]?
286 [-\/]?
289 (?:\s+|[-:Tt]) # separator before clock
295 ([-+]?\d\d?:?(:?\d\d)?
303 1994-02-03 14:15:29 -0100 -- ISO 8601 format
304 1994-02-03 14:15:29 -- zone is optional
305 1994-02-03 -- only date
306 1994-02-03T14:15:29 -- Use T as separator
307 19940203T141529Z -- ISO 8601 compact format
308 19940203 -- only date
330 # -----------------------------------------------------------------------------
364 quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
366 quoted-pair = "\" CHAR
370 value = token | quoted-string
380 >>> split_header_words(['text/html; charset="iso-8859-1"'])
381 [[('text/html', None), ('charset', 'iso-8859-1')]]
408 # no value, a lone token
433 >>> join_header_words([[("text/plain", None), ("charset", "iso-8859-1")]])
434 'text/plain; charset="iso-8859-1"'
435 >>> join_header_words([[("text/plain", None)], [("charset", "iso-8859-1")]])
436 'text/plain, charset="iso-8859-1"'
445 v = HEADER_JOIN_ESCAPE_RE.sub(r"\\\1", v) # escape " and \
456 text = text[:-1]
460 """Ad-hoc parser for Netscape protocol cookie-attributes.
462 The old Netscape cookie format for Set-Cookie can for instance contain
463 an unquoted "," in the expires field, so we have to use this ad-hoc
476 "version", "port", "max-age")
539 if text[0] == "." or text[-1] == ".":
544 """Return True if domain A domain-matches domain B, according to RFC 2965.
552 be case-insensitive.) Host A's name domain-matches host B's if
554 * their host name strings string-compare equal; or
556 * A is a HDN string and has the form NB, where N is a non-empty
558 x.y.com domain-matches .Y.com but not Y.com.)
560 Note that domain-match is not a commutative operation: a.b.c.com
561 domain-matches .c.com, but not the reverse.
565 # definition of the domain-match algorithm is the direct string-compare.
573 if i == -1 or i == 0:
583 """Return True if text is a sort-of-like a host domain name.
614 """Return request-host, as defined by RFC 2965.
630 """Return a tuple (request-host, effective request-host name).
636 if req_host.find(".") == -1 and not IPV4_RE.search(req_host):
641 """Path component of request-URI, as defined by RFC 2965."""
664 # Characters in addition to A-Z, a-z, 0-9, '_', '.', and '-' that don't
667 ESCAPED_CHAR_RE = re.compile(r"%([0-9a-fA-F][0-9a-fA-F])")
671 """Escape any invalid characters in HTTP URL, and uppercase all escapes."""
672 # There's no knowing what character encoding was used to create URLs
673 # containing %-escapes, but since we have to pick one to escape invalid
674 # path characters, we pick UTF-8, as recommended in the HTML 4.0
676 # http://www.w3.org/TR/REC-html40/appendix/notes.html#h-B.2.1
677 # And here, kind of: draft-fielding-uri-rfc2396bis-03
678 # (And in draft IRI specification: draft-duerst-iri-05)
691 - H is the host domain name of a host; and,
693 - H has the form A.B; and
695 - A has no embedded (that is, interior) dots; and
697 - B has at least one embedded dot, or B is the string "local".
724 An unverifiable transaction is to a third-party host if its request-
725 host U does not domain-match the reach R of the request-host O in the
744 objects -- it deals with cookie parsing, supplying defaults, and
781 # cookie-attribute had an initial dot, in order to follow RFC 2965
840 and RFC 2965 cookies -- override that if you want a customized policy.
846 Currently, pre-expired cookies never get this far -- the CookieJar
949 _debug(" - checking cookie %s=%s", cookie.name, cookie.value)
965 _debug(" Set-Cookie2 without version attribute (%s=%s)",
979 _debug(" third-party RFC 2965 cookie during "
983 _debug(" third-party Netscape cookie during "
1010 _debug(" domain %s is in user block-list", cookie.domain)
1013 _debug(" domain %s is not in user allow-list", cookie.domain)
1032 _debug(" country-code second level domain %s", domain)
1040 _debug(" non-local domain %s contains no embedded dot",
1047 _debug(" effective request-host %s (even with added "
1054 _debug(" effective request-host %s does not domain-match "
1059 host_prefix = req_host[:-len(domain)]
1097 _debug(" - checking cookie %s=%s", cookie.name, cookie.value)
1118 _debug(" third-party RFC 2965 cookie during unverifiable "
1122 _debug(" third-party Netscape cookie during unverifiable "
1129 _debug(" secure cookie with non-secure request")
1162 # strict check of non-domain cookies: Mozilla does this, MSIE5 doesn't
1166 _debug(" cookie with unspecified domain does not string-compare "
1171 _debug(" effective request-host name %s does not domain-match "
1175 _debug(" request-host %s does not match Netscape cookie domain "
1198 _debug(" domain %s is in user block-list", domain)
1201 _debug(" domain %s is not in user allow-list", domain)
1207 _debug("- checking cookie path=%s", path)
1216 _debug(" %s does not path-match %s", req_path, path)
1224 """Iterates over nested mapping, depth-first, in sorted order by key."""
1256 magic_re = re.compile(r"^\#LWP-Cookies-(\d+\.\d+)", re.ASCII)
1295 """Return a list of cookie-attributes to be returned to server.
1312 # What should it be if multiple matching Set-Cookie headers have
1314 # Answer: there is no answer; was supposed to be settled by
1324 # intact, due to the poorly-specified Netscape Cookie: syntax)
1331 # add cookie-attributes to be returned in Cookie header
1390 the Set-Cookie or Set-Cookie2 headers.
1394 cookie-attributes (discard, secure, version, expires or max-age,
1396 the cookie-attributes.
1403 "expires", "max-age",
1410 # Build dictionary of standard cookie-attributes (standard) and
1411 # dictionary of other cookie-attributes (rest).
1414 # cookies should have the Expires cookie-attribute, and V1 cookies
1415 # should have Max-Age, but since V1 includes RFC 2109 cookies (and
1416 # since V0 cookies may be a mish-mash of Netscape and RFC 2109), we
1417 # accept either (but prefer Max-Age).
1430 # boolean cookie-attribute is present, but has no value
1445 # Prefer max-age to expires (like Mozilla)
1451 if k == "max-age":
1456 _debug(" missing or invalid (non-numeric) value for "
1457 "max-age attribute")
1460 # convert RFC 2965 Max-Age to seconds since epoch
1462 # age-calculation rules. Remember that zero Max-Age
1484 # standard is dict of standard cookie-attributes, rest is dict of the
1514 if i != -1:
1538 # Port attr present, but has no value: default to request port.
1545 # No port attr present. Cookie can be sent back on any port.
1598 # get cookie-attributes for RFC 2965 and Netscape protocols
1600 rfc2965_hdrs = headers.get_all("Set-Cookie2", [])
1601 ns_hdrs = headers.get_all("Set-Cookie", [])
1611 return [] # no relevant cookie headers: quick exit
1630 # Look for Netscape cookies (from Set-Cookie headers) that match
1631 # corresponding RFC 2965 cookies (from Set-Cookie2 headers).
1698 Raises KeyError if no matching cookie exists.
1770 # derives from OSError for backwards-compatibility with Python 2.4.0
1831 Actually, the format is extended a bit -- see module docstring.
1858 The LWPCookieJar saves a sequence of "Set-Cookie3" lines.
1859 "Set-Cookie3" is the format used by the libwww-perl library, not known
1870 """Return cookies as a string of "\\n"-separated "Set-Cookie3" headers.
1882 r.append("Set-Cookie3: %s" % lwp_cookie_str(cookie))
1893 # port_spec) while still being compatible with libwww-perl, I hope.
1894 f.write("#LWP-Cookies-2.0\n")
1900 msg = ("%r does not look like a Set-Cookie3 (LWP) format "
1906 header = "Set-Cookie3:"
1972 raise LoadError("invalid Set-Cookie3 format file %r: %r" %
1997 specified by the Set-Cookie2 (or Set-Cookie) header, and whether or not the
1999 domains in Netscape files start with a dot and some don't -- trust me, you
2030 if line.endswith("\n"): line = line[:-1]
2042 # cookies.txt regards 'Set-Cookie: foo' as a cookie
2043 # with no name, whereas http.cookiejar regards it as a
2044 # cookie with no value.
2102 # cookies.txt regards 'Set-Cookie: foo' as a cookie
2103 # with no name, whereas http.cookiejar regards it as a
2104 # cookie with no value.