Ignore:
Timestamp:
Mar 19, 2014, 11:11:30 AM (11 years ago)
Author:
dmik
Message:

python: Update vendor to 2.7.6.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/vendor/current/Lib/cookielib.py

    r2 r388  
    1 """HTTP cookie handling for web clients.
     1r"""HTTP cookie handling for web clients.
    22
    33This module has (now fairly distant) origins in Gisle Aas' Perl module
     
    435435    return ", ".join(headers)
    436436
     437def _strip_quotes(text):
     438    if text.startswith('"'):
     439        text = text[1:]
     440    if text.endswith('"'):
     441        text = text[:-1]
     442    return text
     443
    437444def parse_ns_headers(ns_headers):
    438445    """Ad-hoc parser for Netscape protocol cookie-attributes.
     
    452459    known_attrs = ("expires", "domain", "path", "secure",
    453460                   # RFC 2109 attrs (may turn up in Netscape cookies, too)
    454                    "port", "max-age")
     461                   "version", "port", "max-age")
    455462
    456463    result = []
     
    472479                if k == "version":
    473480                    # This is an RFC 2109 cookie.
     481                    v = _strip_quotes(v)
    474482                    version_set = True
    475483                if k == "expires":
    476484                    # convert expires date to seconds since epoch
    477                     if v.startswith('"'): v = v[1:]
    478                     if v.endswith('"'): v = v[:-1]
    479                     v = http2time(v)  # None if invalid
     485                    v = http2time(_strip_quotes(v))  # None if invalid
    480486            pairs.append((k, v))
    481487
     
    602608
    603609def request_path(request):
    604     """request-URI, as defined by RFC 2965."""
     610    """Path component of request-URI, as defined by RFC 2965."""
    605611    url = request.get_full_url()
    606     #scheme, netloc, path, parameters, query, frag = urlparse.urlparse(url)
    607     #req_path = escape_path("".join(urlparse.urlparse(url)[2:]))
    608     path, parameters, query, frag = urlparse.urlparse(url)[2:]
    609     if parameters:
    610         path = "%s;%s" % (path, parameters)
    611     path = escape_path(path)
    612     req_path = urlparse.urlunparse(("", "", path, "", query, frag))
    613     if not req_path.startswith("/"):
     612    parts = urlparse.urlsplit(url)
     613    path = escape_path(parts.path)
     614    if not path.startswith("/"):
    614615        # fix bad RFC 2396 absoluteURI
    615         req_path = "/"+req_path
    616     return req_path
     616        path = "/" + path
     617    return path
    617618
    618619def request_port(request):
     
    10141015                     not ("."+erhn).endswith(domain))):
    10151016                    _debug("   effective request-host %s (even with added "
    1016                            "initial dot) does not end end with %s",
     1017                           "initial dot) does not end with %s",
    10171018                           erhn, domain)
    10181019                    return False
     
    14511452        # set the easy defaults
    14521453        version = standard.get("version", None)
    1453         if version is not None: version = int(version)
     1454        if version is not None:
     1455            try:
     1456                version = int(version)
     1457            except ValueError:
     1458                return None  # invalid version, ignore cookie
    14541459        secure = standard.get("secure", False)
    14551460        # (discard is also set if expires is Absent)
Note: See TracChangeset for help on using the changeset viewer.