diff options
| -rw-r--r-- | pyramid/config/views.py | 2 | ||||
| -rw-r--r-- | pyramid/tests/test_config/test_views.py | 10 |
2 files changed, 11 insertions, 1 deletions
diff --git a/pyramid/config/views.py b/pyramid/config/views.py index 190eefc98..022984420 100644 --- a/pyramid/config/views.py +++ b/pyramid/config/views.py @@ -1913,7 +1913,7 @@ class StaticURLInfo(object): if '_query' in kw: query = kw.pop('_query') if isinstance(query, text_type): - result += '?' + native_(query) + result += '?' + quote_plus(query) elif query: result += '?' + urlencode(query, doseq=True) if '_anchor' in kw: diff --git a/pyramid/tests/test_config/test_views.py b/pyramid/tests/test_config/test_views.py index a7e32f0c6..832921713 100644 --- a/pyramid/tests/test_config/test_views.py +++ b/pyramid/tests/test_config/test_views.py @@ -3820,6 +3820,16 @@ class TestStaticURLInfo(unittest.TestCase): result = inst.generate('package:path/abc def', request, a=1) self.assertEqual(result, 'http://example.com/abc%20def') + def test_generate_url_with_custom_query(self): + inst = self._makeOne() + registrations = [('http://example.com/', 'package:path/', None)] + inst._get_registrations = lambda *x: registrations + request = self._makeRequest() + result = inst.generate('package:path/abc def', request, a=1, + _query='(openlayers)') + self.assertEqual(result, + 'http://example.com/abc%20def?%28openlayers%29') + def test_generate_url_with_custom_anchor(self): inst = self._makeOne() registrations = [('http://example.com/', 'package:path/', None)] |
