Imported Debian patch 4.0.5-6~numeezy

This commit is contained in:
Alexandre Ellert
2016-02-17 15:07:45 +01:00
committed by Mario Fetka
parent c44de33144
commit 10dfc9587b
1203 changed files with 53869 additions and 241462 deletions

View File

@@ -21,11 +21,8 @@ import re
import time
import datetime
import email.utils
from urllib2 import urlparse
from calendar import timegm
import six
from six.moves.urllib.parse import urlparse
from ipapython.ipa_log_manager import log_mgr
'''
@@ -49,7 +46,7 @@ the relevant RFC's as well as actual practice in the field. However
cookielib.py is tighly integrated with urllib2 and it's not possible
to use most of the features of cookielib without simultaneously using
urllib2. Unfortunataely we only use httplib because of our dependency
on xmlrpc.client. Without urllib2 cookielib is a non-starter.
on xmlrpclib. Without urllib2 cookielib is a non-starter.
This module is a minimal implementation of Netscape cookies which
works equally well on either the client or server side. It's API is
@@ -188,7 +185,7 @@ class Cookie(object):
try:
dt = datetime.datetime(*email.utils.parsedate(s)[0:6])
except Exception as e:
except Exception, e:
raise ValueError("unable to parse expires datetime '%s': %s" % (s, e))
return dt
@@ -273,9 +270,8 @@ class Cookie(object):
if match:
key = match.group(1)
value = match.group(2)
# Double quoted value?
if value and value[0] == '"':
if value[0] == '"':
if value[-1] == '"':
value = value[1:-1]
else:
@@ -392,9 +388,9 @@ class Cookie(object):
self._timestamp = None
elif isinstance(value, datetime.datetime):
self._timestamp = value
elif isinstance(value, (six.integer_types, float)):
elif isinstance(value, (int, long, float)):
self._timestamp = datetime.datetime.utcfromtimestamp(value)
elif isinstance(value, six.string_types):
elif isinstance(value, basestring):
self._timestamp = Cookie.parse_datetime(value)
else:
raise TypeError('value must be datetime, int, long, float, basestring or None, not %s' % \
@@ -418,9 +414,9 @@ class Cookie(object):
self._expires = None
elif isinstance(value, datetime.datetime):
self._expires = value
elif isinstance(value, (six.integer_types, float)):
elif isinstance(value, (int, long, float)):
self._expires = datetime.datetime.utcfromtimestamp(value)
elif isinstance(value, six.string_types):
elif isinstance(value, basestring):
self._expires = Cookie.parse_datetime(value)
else:
raise TypeError('value must be datetime, int, long, float, basestring or None, not %s' % \
@@ -541,7 +537,7 @@ class Cookie(object):
received from.
'''
scheme, domain, path, params, query, fragment = urlparse(url)
scheme, domain, path, params, query, fragment = urlparse.urlparse(url)
if self.domain is None:
self.domain = domain.lower()
@@ -598,7 +594,7 @@ class Cookie(object):
from ipalib.util import validate_domain_name
try:
validate_domain_name(url_domain)
except Exception as e:
except Exception, e:
return False
if cookie_domain is None:
@@ -643,7 +639,7 @@ class Cookie(object):
cookie_name = self.key
url_scheme, url_domain, url_path, url_params, url_query, url_fragment = urlparse(url)
url_scheme, url_domain, url_path, url_params, url_query, url_fragment = urlparse.urlparse(url)
cookie_expiration = self.get_expiration()
if cookie_expiration is not None: