Fix unquoting of positional args with plus sign
Closes-Bug: #1425750 Change-Id: I60616299b7853b0587ff25b74bfc155dc7589204
This commit is contained in:
parent
9a6a893d5e
commit
472131549f
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue