Skip to content

Commit

Permalink
Correctly escape sort-by columns in SQL (refs #189)
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw authored and Simon Willison committed Apr 9, 2018
1 parent 747a801 commit bfb19e3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions datasette/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -616,10 +616,10 @@ async def data(self, request, name, hash, table):
# Allow for custom sort order
sort = special_args.get('_sort')
if sort:
order_by = sort
order_by = escape_sqlite(sort)
sort_desc = special_args.get('_sort_desc')
if sort_desc:
order_by = '{} desc'.format(sort_desc)
order_by = '{} desc'.format(escape_sqlite(sort_desc))

count_sql = 'select count(*) from {table_name} {where}'.format(
table_name=escape_sqlite(table),
Expand Down

0 comments on commit bfb19e3

Please sign in to comment.