mirror of
https://github.com/pallets-eco/flask-debugtoolbar.git
synced 2025-12-31 10:39:33 -06:00
Compare commits
3 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6286dadc27 | ||
|
|
82295aa4aa | ||
|
|
70488fc14a |
11
CHANGES.rst
11
CHANGES.rst
@@ -1,8 +1,17 @@
|
||||
Changes
|
||||
=======
|
||||
|
||||
0.9.1 (2014-11-24)
|
||||
------------------
|
||||
|
||||
Fixes:
|
||||
|
||||
- Fix SQL queries with byte strings on Python 3
|
||||
- Fix displaying values whose `repr()` contains unprintable characters
|
||||
|
||||
|
||||
0.9.0 (2014-01-03)
|
||||
--------
|
||||
------------------
|
||||
|
||||
Enhancements:
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ copyright = u'2012, Matt Good'
|
||||
# The short X.Y version.
|
||||
version = '0.9'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '0.9.0'
|
||||
release = '0.9.1'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
@@ -30,7 +30,10 @@ def replace_insensitive(string, target, replacement):
|
||||
|
||||
def _printable(value):
|
||||
try:
|
||||
return repr(value)
|
||||
value = repr(value)
|
||||
if isinstance(value, bytes):
|
||||
value = value.decode('ascii', 'replace')
|
||||
return value
|
||||
except Exception as e:
|
||||
return '<repr(%s) raised %s: %s>' % (
|
||||
object.__repr__(value), type(e).__name__, e)
|
||||
|
||||
@@ -21,8 +21,13 @@ def query_signer():
|
||||
salt='fdt-sql-query')
|
||||
|
||||
|
||||
def is_select(statement):
|
||||
prefix = b'select' if isinstance(statement, bytes) else 'select'
|
||||
return statement.lower().strip().startswith(prefix)
|
||||
|
||||
|
||||
def dump_query(statement, params):
|
||||
if not params or not statement.lower().strip().startswith('select'):
|
||||
if not params or not is_select(statement):
|
||||
return None
|
||||
|
||||
try:
|
||||
@@ -38,7 +43,7 @@ def load_query(data):
|
||||
abort(406)
|
||||
|
||||
# Make sure it is a select statement
|
||||
if not statement.lower().strip().startswith('select'):
|
||||
if not is_select(statement):
|
||||
abort(406)
|
||||
|
||||
return statement, params
|
||||
|
||||
2
setup.py
2
setup.py
@@ -14,7 +14,7 @@ except:
|
||||
|
||||
setup(
|
||||
name='Flask-DebugToolbar',
|
||||
version='0.9.0',
|
||||
version='0.9.1',
|
||||
url='http://flask-debugtoolbar.rtfd.org/',
|
||||
license='BSD',
|
||||
author='Michael van Tellingen',
|
||||
|
||||
@@ -1,3 +1,10 @@
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
|
||||
from flask_debugtoolbar import _printable
|
||||
|
||||
|
||||
def load_app(name):
|
||||
app = __import__(name).app
|
||||
app.config['TESTING'] = True
|
||||
@@ -9,3 +16,26 @@ def test_basic_app():
|
||||
index = app.get('/')
|
||||
assert index.status_code == 200
|
||||
assert b'<div id="flDebug"' in index.data
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info >= (3,),
|
||||
reason='test only applies to Python 2')
|
||||
def test_printable_unicode():
|
||||
class UnicodeRepr(object):
|
||||
def __repr__(self):
|
||||
return u'\uffff'
|
||||
|
||||
printable = _printable(UnicodeRepr())
|
||||
assert "raised UnicodeEncodeError: 'ascii' codec" in printable
|
||||
|
||||
|
||||
@pytest.mark.skipif(sys.version_info >= (3,),
|
||||
reason='test only applies to Python 2')
|
||||
def test_printable_non_ascii():
|
||||
class NonAsciiRepr(object):
|
||||
def __repr__(self):
|
||||
return 'a\xffb'
|
||||
|
||||
printable = u'%s' % _printable(NonAsciiRepr())
|
||||
# should replace \xff with the unicode ? character
|
||||
assert printable == u'a\ufffdb'
|
||||
|
||||
Reference in New Issue
Block a user