summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaxim Kulkin <mkulkin@mirantis.com>2015-02-25 15:54:36 -0800
committerRyan Petrello <lists@ryanpetrello.com>2015-05-12 17:20:40 -0400
commit472131549f0afbaa6bff034019163a8dae19c549 (patch)
treec393783545f620538e02030e77ca781d3757df89
parent9a6a893d5e2f090087be92d301705e35ccf158ba (diff)
downloadpecan-472131549f0afbaa6bff034019163a8dae19c549.tar.gz
Fix unquoting of positional args with plus sign
Closes-Bug: #1425750 Change-Id: I60616299b7853b0587ff25b74bfc155dc7589204
-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