Skip to content

Commit

Permalink
Merge pull request #37 from golnazads/master
Browse files Browse the repository at this point in the history
fixed utf-8 issue found by Roman
  • Loading branch information
golnazads committed May 4, 2018
2 parents 0575194 + 4cb9be7 commit 48ced59
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions tugboat/views.py
Expand Up @@ -335,8 +335,7 @@ def translate_authors(self, args):
search += urllib.quote(author_field) + '('
for author in authors:
if len(author) > 1:
# make sure user has not specified double quotes, and then put author in double quote
search += urllib.quote('"' + author.replace('"', '') + '"' + connector)
search += urllib.quote(author.encode('utf8') + connector)
search = search[:-len(urllib.quote(connector))] # remove final
search += ')'
# fields in search are ORed
Expand All @@ -357,10 +356,10 @@ def translate_simple(self, args, classic_param, bbb_param):
# one lone parameter should hold all authors from classic
classic_str = args.pop(classic_param, None)
if classic_str:
terms = ClassicSearchRedirectView.classic_field_to_array(classic_str)
terms = self.classic_field_to_array(classic_str)
search += urllib.quote(bbb_param + ':') + '('
for term in terms:
search += urllib.quote(term + connector)
search += urllib.quote(term.encode('utf8') + connector)
search = search[:-len(urllib.quote(connector))] # remove final connector
search += ')'
# fields in search are ORed
Expand Down Expand Up @@ -855,7 +854,7 @@ def classic_field_to_array(value):
for i in range(0, len(values)):
values[i] = values[i].replace('+', ' ')
if ' ' in values[i] and (values[i].startswith('"') and values[i].endswith('"')) is False:
# value has space and is not already surrounded by double quotes so we add quotes
# always surround by double quotes if not already
values[i] = '"' + values[i] + '"'
return values

Expand Down

0 comments on commit 48ced59

Please sign in to comment.