diff options
Diffstat (limited to 'chimere/views.py')
-rw-r--r-- | chimere/views.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/chimere/views.py b/chimere/views.py index a696d5a..8daa432 100644 --- a/chimere/views.py +++ b/chimere/views.py @@ -962,9 +962,15 @@ if hasattr(settings, 'CHIMERE_SEARCH_ENGINE') \ sqs = SearchQuerySet().autocomplete( content_auto=request.GET.get('q', ''))[:5] suggestions = [result.object.name for result in sqs if result.object] + spelling = [] + if not suggestions: + spelling = SearchQuerySet().spelling_suggestion( + request.GET.get('q', '')) or [] + # convert to list spelling... # make sure it returns a JSON object, not a bare list. # otherwise, it could be vulnerable to an XSS attack. the_data = json.dumps({ - 'results': suggestions + 'results': suggestions, + 'spelling':spelling, }) return HttpResponse(the_data, content_type='application/json') |