summaryrefslogtreecommitdiff
path: root/webob
diff options
context:
space:
mode:
Diffstat (limited to 'webob')
-rw-r--r--webob/request.py17
-rw-r--r--webob/response.py13
-rw-r--r--webob/util.py2
3 files changed, 22 insertions, 10 deletions
diff --git a/webob/request.py b/webob/request.py
index f76b754..50bb407 100644
--- a/webob/request.py
+++ b/webob/request.py
@@ -281,8 +281,16 @@ class BaseRequest(object):
parse_int, serialize_int, 'int')
# raw wsgi values (bytes on py2, bytes-tunneled-via-text on py3)
- script_name = environ_getter('SCRIPT_NAME', '')
- path_info = environ_getter('PATH_INFO')
+ script_name = deprecated_property(
+ environ_getter('SCRIPT_NAME', ''),
+ 'script_name',
+ 'deprecated in WebOb 1.2, use scriptname or scriptname_bytes instead',
+ '1.4')
+ path_info = deprecated_property(
+ environ_getter('PATH_INFO'),
+ 'path_info',
+ 'deprecated in WebOb 1.2, use pathinfo or pathinfo_bytes instead',
+ '1.4')
if PY3: # pragma: no cover
def _bytes_to_wsgi(self, val):
@@ -671,7 +679,8 @@ class BaseRequest(object):
Optional ``pattern`` argument is a regexp to match the return value
before returning. If there is no match, no changes are made to the
- request and None is returned.
+ request and None is returned. The pattern must always match against
+ a bytes object (not unicode).
"""
path = self.pathinfo_bytes
if not path:
@@ -684,7 +693,7 @@ class BaseRequest(object):
if idx == -1:
idx = len(path)
r = path[:idx]
- if pattern is None or re.match(pattern, r.decode(self.url_encoding)):
+ if pattern is None or re.match(pattern, r):
self.scriptname_bytes += slashes + r
self.pathinfo_bytes = path[idx:]
return r
diff --git a/webob/response.py b/webob/response.py
index 83931f8..20b0e47 100644
--- a/webob/response.py
+++ b/webob/response.py
@@ -934,8 +934,10 @@ class Response(object):
if name.lower() == 'location':
if SCHEME_RE.search(value):
break
- new_location = urlparse.urljoin(
- _request_uri(environ), value)
+ uri = _request_uri(environ)
+ if not uri.endswith('/'):
+ uri += '/'
+ new_location = urlparse.urljoin(uri, value)
headerlist = list(headerlist)
idx = headerlist.index((name, value))
headerlist[idx] = (name, new_location)
@@ -1152,16 +1154,17 @@ def _request_uri(environ):
script_name = environ.get('SCRIPT_NAME') or '/'
path_info = environ.get('PATH_INFO','')
+
if PY3: # pragma: no cover
script_name = script_name.encode('latin-1').decode('utf-8')
path_info = path_info.encode('latin-1').decode('utf-8')
url += url_quote(script_name)
path_info = url_quote(path_info)
- if not environ.get('SCRIPT_NAME'):
- url += path_info[1:]
- else:
+ if environ.get('SCRIPT_NAME'):
url += path_info
+ else:
+ url += path_info[1:]
return url
diff --git a/webob/util.py b/webob/util.py
index b740088..6b838b4 100644
--- a/webob/util.py
+++ b/webob/util.py
@@ -49,7 +49,7 @@ def warn_deprecation(text, version, stacklevel): # pragma: no cover
# version specifies when to start raising exceptions instead of warnings
if version == '1.2':
raise DeprecationWarning(text)
- elif version == '1.3':
+ elif version in ('1.3', '1.4'):
cls = DeprecationWarning
else:
cls = DeprecationWarning