_search= queries now correctly escaped, fixes #651

Queries with reserved words or characters according to the SQLite
FTS5 query language could cause errors.

Queries are now escaped like so:

    dog cat => "dog" "cat"
This commit is contained in:
Simon Willison 2019-12-29 18:48:13 +00:00
commit 3c861f363d
6 changed files with 47 additions and 2 deletions

View file

@ -947,6 +947,11 @@ def test_sortable_columns_metadata(app_client):
[2, "terry dog", "sara weasel", "puma"],
],
),
(
# Special keyword shouldn't break FTS query
"/fixtures/searchable.json?_search=AND",
[],
),
(
"/fixtures/searchable.json?_search=weasel",
[[2, "terry dog", "sara weasel", "puma"]],