Codebase list python-werkzeug / e2b21c2
Import python-werkzeug_0.11.11+dfsg1.orig.tar.gz Ondřej Nový 7 years ago
14 changed file(s) with 74 addition(s) and 18 deletion(s). Raw diff Collapse all Expand all
1616 PYENV_ROOT="$HOME/.pyenv";
1717 PATH="$PYENV_ROOT/bin:$PATH";
1818 eval "$(pyenv init -)";
19 pyenv install pypy-2.6.1;
20 pyenv global pypy-2.6.1;
19 pyenv install pypy-4.0.1;
20 pyenv global pypy-4.0.1;
2121 fi
2222 - python --version
2323 - pip install tox flake8
2424
2525 script:
2626 - tox -e py
27 - make stylecheck
27 - '[ "$TRAVIS_PYTHON_VERSION" = "2.6" ] || make stylecheck'
2828
2929 branches:
3030 except:
2727 - Daniel Neuhäuser
2828 - Markus Unterwaditzer
2929 - Joe Esposito <joe@joeyespo.com>
30 - Cédric Krier
31 - Lars Holm Nielsen
3032
3133 Contributors of code for werkzeug/examples are:
3234
00 Werkzeug Changelog
11 ==================
2
3 Version 0.11.11
4 ---------------
5
6 Released on August 31st 2016.
7
8 - Fix JSONRequestMixin for Python3. See #731
9 - Fix broken string handling in test client when passing integers. See #852
10 - Fix a bug in ``parse_options_header`` where an invalid content type
11 starting with comma or semi-colon would result in an invalid return value,
12 see issue ``#995``.
13 - Fix a bug in multidicts when passing empty lists as values, see issue
14 ``#979``.
15 - Fix a security issue that allows XSS on the Werkzeug debugger. See ``#1001``.
216
317 Version 0.11.10
418 ---------------
276290 object (pull request ``#583``).
277291 - The ``qop`` parameter for ``WWW-Authenticate`` headers is now always quoted,
278292 as required by RFC 2617 (issue ``#633``).
279 - Fix bug in ``werkzeug.contrib.cache.SimpleCache`` with Python 3 where add/set
293 - Fix bug in ``werkzeug.contrib.cache.SimpleCache`` with Python 3 where add/set
280294 may throw an exception when pruning old entries from the cache (pull request
281295 ``#651``).
282296
1313 from werkzeug.contrib import wrappers
1414 from werkzeug import routing
1515 from werkzeug.wrappers import Request, Response
16
17
18 def test_json_request_mixin():
19 class MyRequest(wrappers.JSONRequestMixin, Request):
20 pass
21 req = MyRequest.from_values(
22 data=u'{"foä": "bar"}'.encode('utf-8'),
23 content_type='text/json'
24 )
25 assert req.json == {u'foä': 'bar'}
1626
1727
1828 def test_reverse_slash_behavior():
375375 assert list(zip(md, iterlistvalues(md))) == list(iterlists(md))
376376 assert list(zip(iterkeys(md), iterlistvalues(md))) == \
377377 list(iterlists(md))
378
379 def test_getitem_raise_badrequestkeyerror_for_empty_list_value(self):
380 mapping = [('a', 'b'), ('a', 'c')]
381 md = self.storage_class(mapping)
382
383 md.setlistdefault('empty', [])
384
385 with pytest.raises(KeyError):
386 md['empty']
378387
379388
380389 class TestOrderedMultiDict(_MutableMultiDictTests):
265265 'text/x-dvi; q=0.8, text/x-c') == \
266266 ('text/plain', {'q': '0.5'})
267267
268 def test_parse_options_header_broken_values(self):
269 # Issue #995
270 assert http.parse_options_header(' ') == ('', {})
271 assert http.parse_options_header(' , ') == ('', {})
272 assert http.parse_options_header(' ; ') == ('', {})
273 assert http.parse_options_header(' ,; ') == ('', {})
274 assert http.parse_options_header(' , a ') == ('', {})
275 assert http.parse_options_header(' ; a ') == ('', {})
276
268277 def test_dump_options_header(self):
269278 assert http.dump_options_header('foo', {'bar': 42}) == \
270279 'foo; bar=42'
142142 assert b.content_type == 'application/x-www-form-urlencoded'
143143 b.files.add_file('test', BytesIO(b'test contents'), 'test.txt')
144144 assert b.files['test'].content_type == 'text/plain'
145 b.form['test_int'] = 1
145146 assert b.content_type == 'multipart/form-data'
146147
147148 req = b.get_request()
638638
639639
640640 def test_form_parsing_failed():
641 data = (
642 b'--blah\r\n'
643 )
644 data = wrappers.Request.from_values(
641 data = b'--blah\r\n'
642 request = wrappers.Request.from_values(
645643 input_stream=BytesIO(data),
646644 content_length=len(data),
647645 content_type='multipart/form-data; boundary=foo',
648646 method='POST'
649647 )
650 assert not data.files
651 assert not data.form
648 assert not request.files
649 assert not request.form
650
651 # Bad Content-Type
652 data = b'test'
653 request = wrappers.Request.from_values(
654 input_stream=BytesIO(data),
655 content_length=len(data),
656 content_type=', ',
657 method='POST'
658 )
659 assert not request.form
652660
653661
654662 def test_file_closing():
1919 from werkzeug._compat import iteritems
2020
2121 # the version. Usually set automatically by a script.
22 __version__ = '0.11.10'
22 __version__ = '0.11.11-dev'
2323
2424
2525 # This import magic raises concerns quite often which is why the implementation
5555 if 'json' not in self.environ.get('CONTENT_TYPE', ''):
5656 raise BadRequest('Not a JSON request')
5757 try:
58 return loads(self.data)
58 return loads(self.data.decode(self.charset, self.encoding_errors))
5959 except Exception:
6060 raise BadRequest('Unable to read JSON request')
6161
371371 tmp = {}
372372 for key, value in iteritems(mapping):
373373 if isinstance(value, (tuple, list)):
374 if len(value) == 0:
375 continue
374376 value = list(value)
375377 else:
376378 value = [value]
397399 :raise KeyError: if the key does not exist.
398400 """
399401 if key in self:
400 return dict.__getitem__(self, key)[0]
402 lst = dict.__getitem__(self, key)
403 if len(lst) > 0:
404 return lst[0]
401405 raise exceptions.BadRequestKeyError(key)
402406
403407 def __setitem__(self, key, value):
357357 'exception': exc,
358358 'exception_type': escape(self.exception_type),
359359 'summary': self.render_summary(include_title=False),
360 'plaintext': self.plaintext,
360 'plaintext': escape(self.plaintext),
361361 'plaintext_cs': re.sub('-{2,}', '-', self.plaintext),
362362 'traceback_id': self.id,
363363 'secret': secret
335335 :return: (mimetype, options) or (mimetype, options, mimetype, options, …)
336336 if multiple=True
337337 """
338
339338 if not value:
340339 return '', {}
341340
367366 return tuple(result)
368367 value = rest
369368
370 return tuple(result)
369 return tuple(result) if result else ('', {})
371370
372371
373372 def parse_accept_header(value, cls=None):
9898 else:
9999 if not isinstance(value, string_types):
100100 value = str(value)
101 else:
102 value = to_bytes(value, charset)
101
102 value = to_bytes(value, charset)
103103 write('\r\n\r\n')
104104 write_binary(value)
105105 write('\r\n')