summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2015-05-13 12:59:44 +0000
committerGerrit Code Review <review@openstack.org>2015-05-13 12:59:44 +0000
commitbf032429122b6a588748cd64ad9a4b50aa4e8289 (patch)
tree64502cdf6fdbcdf6d6a7e1383d1a8a76be33aa60
parentc3ce70b61356f3bdec8e4b5253560425ecf2dbf2 (diff)
parent472131549f0afbaa6bff034019163a8dae19c549 (diff)
downloadpecan-bf032429122b6a588748cd64ad9a4b50aa4e8289.tar.gz
Merge "Fix unquoting of positional args with plus sign"
-rw-r--r--pecan/core.py8
-rw-r--r--pecan/tests/test_base.py20
2 files changed, 22 insertions, 6 deletions
diff --git a/pecan/core.py b/pecan/core.py
index 141e7c3..a6525ca 100644
--- a/pecan/core.py
+++ b/pecan/core.py
@@ -16,7 +16,7 @@ from webob import (Request as WebObRequest, Response as WebObResponse, exc,
acceptparse)
from webob.multidict import NestedMultiDict
-from .compat import urlparse, unquote_plus, izip
+from .compat import urlparse, izip
from .secure import handle_security
from .templating import RendererFactory
from .routing import lookup_controller, NonCanonicalPath
@@ -348,11 +348,7 @@ class PecanBase(object):
valid_args.pop(0) # pop off `self`
pecan_state = state.request.pecan
- def _decode(x):
- return unquote_plus(x) if isinstance(x, six.string_types) \
- else x
-
- remainder = [_decode(x) for x in remainder if x]
+ remainder = [x for x in remainder if x]
if im_self is not None:
args.append(im_self)
diff --git a/pecan/tests/test_base.py b/pecan/tests/test_base.py
index 6332392..e9f6af2 100644
--- a/pecan/tests/test_base.py
+++ b/pecan/tests/test_base.py
@@ -462,6 +462,16 @@ class TestControllerArguments(PecanTestCase):
assert r.status_int == 200
assert r.body == b_('index: This is a test!')
+ def test_single_argument_with_plus(self):
+ r = self.app_.get('/foo+bar')
+ assert r.status_int == 200
+ assert r.body == b_('index: foo+bar')
+
+ def test_single_argument_with_encoded_plus(self):
+ r = self.app_.get('/foo%2Bbar')
+ assert r.status_int == 200
+ assert r.body == b_('index: foo+bar')
+
def test_two_arguments(self):
r = self.app_.get('/1/dummy', status=404)
assert r.status_int == 404
@@ -476,6 +486,16 @@ class TestControllerArguments(PecanTestCase):
assert r.status_int == 200
assert r.body == b_('index: This is a test!')
+ def test_keyword_argument_with_plus(self):
+ r = self.app_.get('/?id=foo+bar')
+ assert r.status_int == 200
+ assert r.body == b_('index: foo bar')
+
+ def test_keyword_argument_with_encoded_plus(self):
+ r = self.app_.get('/?id=foo%2Bbar')
+ assert r.status_int == 200
+ assert r.body == b_('index: foo+bar')
+
def test_argument_and_keyword_argument(self):
r = self.app_.get('/3?id=three')
assert r.status_int == 200