diff options
| -rw-r--r-- | archaeological_operations/tests.py | 5 | ||||
| -rw-r--r-- | ishtar_common/views_item.py | 6 | 
2 files changed, 10 insertions, 1 deletions
| diff --git a/archaeological_operations/tests.py b/archaeological_operations/tests.py index e5c77e501..ec1ca3d17 100644 --- a/archaeological_operations/tests.py +++ b/archaeological_operations/tests.py @@ -1501,6 +1501,11 @@ class OperationSearchTest(TestCase, OperationInitTest):          response = c.get(reverse('get-operation'), {'search_vector': 'château'})          result = json.loads(response.content)          self.assertEqual(result['recordsTotal'], 1) +        # test search with inappropriate minus sign +        response = c.get(reverse('get-operation'), +                         {'search_vector': 'chaTEAU - '}) +        result = json.loads(response.content) +        self.assertEqual(result['recordsTotal'], 1)      def test_complex_search_vector(self):          c = Client() diff --git a/ishtar_common/views_item.py b/ishtar_common/views_item.py index 133e27d39..98415c311 100644 --- a/ishtar_common/views_item.py +++ b/ishtar_common/views_item.py @@ -341,7 +341,7 @@ def _parse_query_string(string, request_keys, current_dct, exc_dct):                      dct[term] += u";" + query                  else:                      dct[term] = query -                return "" +                return u""      for reserved_char in FORBIDDEN_CHAR:          string = string.replace(reserved_char, u"")      if len(string) != 1: @@ -349,8 +349,12 @@ def _parse_query_string(string, request_keys, current_dct, exc_dct):              string = string.replace(reserved_char, u"")      # like search      if string.endswith(u'*'): +        if len(string.strip()) == 1: +            return u""          string = string[:-1] + u':*'      if string.startswith(u'-'): +        if len(string.strip()) == 1: +            return u""          string = u"!" + string[1:]      return string | 
