From afa8a7457384aeb2c621b65f3acccce1ec28c3b9 Mon Sep 17 00:00:00 2001 From: Timur Izhbulatov Date: Tue, 14 Apr 2015 08:42:05 +0400 Subject: Request params starting with '=' may have value --- pyramid/config/predicates.py | 7 +++++-- pyramid/tests/test_config/test_predicates.py | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/pyramid/config/predicates.py b/pyramid/config/predicates.py index fbd214b15..d87fd1aae 100644 --- a/pyramid/config/predicates.py +++ b/pyramid/config/predicates.py @@ -70,8 +70,11 @@ class RequestParamPredicate(object): for p in val: k = p v = None - if '=' in p and not p.startswith('='): - k, v = p.split('=', 1) + if '=' in p: + if p.startswith('='): + k, v = p.rsplit('=', 1) + else: + k, v = p.split('=', 1) k, v = k.strip(), v.strip() reqs.append((k, v)) self.val = val diff --git a/pyramid/tests/test_config/test_predicates.py b/pyramid/tests/test_config/test_predicates.py index 46516f518..ee24de093 100644 --- a/pyramid/tests/test_config/test_predicates.py +++ b/pyramid/tests/test_config/test_predicates.py @@ -157,8 +157,8 @@ class TestRequestParamPredicate(unittest.TestCase): self.assertEqual(inst.text(), 'request_param abc=1,def') def test_text_multi_equal_sign(self): - inst = self._makeOne(('abc= 1', '=def')) - self.assertEqual(inst.text(), 'request_param =def,abc=1') + inst = self._makeOne(('abc= 1', '=def= 2')) + self.assertEqual(inst.text(), 'request_param =def=2,abc=1') def test_phash_exists(self): inst = self._makeOne('abc') -- cgit v1.2.3