--
Ticket URL: <https://code.djangoproject.com/ticket/32649>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
Old description:
> django.contrib.admin.ModelAdmin.search_fields now allows searching
> against quoted phrases with spaces but unfortunately search crashes for a
> search term like **Foo "Foo "Baz"** (with three quotes, some company
> names match such the pattern)
New description:
django.contrib.admin.ModelAdmin.search_fields now allows searching against
quoted phrases with spaces but unfortunately search crashes for a search
term like **Foo "Bar "Baz"** (with three quotes, some company names match
such the pattern)
--
--
Ticket URL: <https://code.djangoproject.com/ticket/32649#comment:1>
Comment (by Dlis):
The bag can be reproduced by the following way:
{{{
from django.utils.text import smart_split
from django.utils.text import unescape_string_literal
search_term = 'Foo "Bar "Baz"'
parts = list(smart_split(search_term))
unescape_string_literal(parts[1])
}}}
Result is {{{ValueError: Not a string literal: '"Bar "Baz'}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32649#comment:2>
Comment (by Dlis):
If somebody has such the problem, here is our temporary fix which was
added to our internal basic ModelAdmin:
{{{
def get_search_results(self, request, queryset, search_term):
parts = search_term.split()
try:
for part in text.smart_split(search_term):
text.unescape_string_literal(part)
except ValueError:
parts = map(lambda t: str(t).strip('"').strip("'"), parts)
return super().get_search_results(request, queryset, ' '.join(parts))
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32649#comment:3>
* owner: nobody => Mariusz Felisiak
* status: new => assigned
* severity: Normal => Release blocker
* stage: Unreviewed => Accepted
Comment:
Thanks for the report.
#6933
Regression in 26a413507abb38f7eee4cf62f2ee9727fdc7bf8d,
Reproduced at 9760e262f85ae57df39abe2799eff48a82b14474.
--
Ticket URL: <https://code.djangoproject.com/ticket/32649#comment:4>
* has_patch: 0 => 1
Comment:
[https://github.com/django/django/pull/14262 PR]
--
Ticket URL: <https://code.djangoproject.com/ticket/32649#comment:5>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"23fa29f6a6659e0f600d216de6bcb79e7f6818c9" 23fa29f6]:
{{{
#!CommitTicketReference repository=""
revision="23fa29f6a6659e0f600d216de6bcb79e7f6818c9"
Fixed #32649 -- Fixed ModelAdmin.search_fields crash when searching
against phrases with unbalanced quotes.
Thanks Dlis for the report.
Regression in 26a413507abb38f7eee4cf62f2ee9727fdc7bf8d.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32649#comment:6>
Comment (by Mariusz Felisiak <felisiak.mariusz@…>):
In [changeset:"59cce8237c9efb33f16058bac67702d5a11ea1d9" 59cce823]:
{{{
#!CommitTicketReference repository=""
revision="59cce8237c9efb33f16058bac67702d5a11ea1d9"
[3.2.x] Fixed #32649 -- Fixed ModelAdmin.search_fields crash when
searching against phrases with unbalanced quotes.
Thanks Dlis for the report.
Regression in 26a413507abb38f7eee4cf62f2ee9727fdc7bf8d.
Backport of 23fa29f6a6659e0f600d216de6bcb79e7f6818c9 from main
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/32649#comment:7>