Skip to content

Commit f1c261f

Browse files
committed
Avoid non-ASCII MySQL exceptions in /doc/search/, too
- Legacy-Id: 2041
1 parent 8c51aa3 commit f1c261f

2 files changed

Lines changed: 11 additions & 1 deletion

File tree

ietf/idrfc/testurl.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
200 /doc/search/?activeDrafts=on&oldDrafts=on&rfcs=on&author=eronen
6565
200 /doc/search/?activeDrafts=on&oldDrafts=on&rfcs=on&area=934&name=ldap
6666
200 /doc/search/?activeDrafts=on&name=asdfsadfsdfasdf
67+
200 /doc/search/?activeDrafts=on&name=%EF%BD%8C #non-ASCII
6768

6869
# Test case for missing publication date
6970
200 /doc/search/?oldDrafts=on&name=ppvpn

ietf/idrfc/views_search.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,11 +64,20 @@ def __init__(self, *args, **kwargs):
6464
self.fields['ad'].choices = [('', 'any AD')] + [(ad.id, "%s %s" % (ad.first_name, ad.last_name)) for ad in IESGLogin.objects.filter(user_level=1).order_by('last_name')] + [('-99', '------------------')] + [(ad.id, "%s %s" % (ad.first_name, ad.last_name)) for ad in IESGLogin.objects.filter(user_level=2).order_by('last_name')]
6565
self.fields['subState'].choices = [('', 'any substate'), ('0', 'no substate')] + [(state.sub_state_id, state.sub_state) for state in IDSubState.objects.all()]
6666

67-
def search_query(query):
67+
def search_query(query_original):
68+
query = dict(query_original.items())
6869
drafts = query['activeDrafts'] or query['oldDrafts']
6970
if (not drafts) and (not query['rfcs']):
7071
return ([], {})
7172

73+
# Non-ASCII strings don't match anything; this check
74+
# is currently needed to avoid complaints from MySQL.
75+
for k in ['name','author','group']:
76+
try:
77+
tmp = str(query.get(k, ''))
78+
except:
79+
query[k] = '*NOSUCH*'
80+
7281
# Start by search InternetDrafts
7382
idresults = []
7483
rfcresults = []

0 commit comments

Comments
 (0)