Skip to content

Commit 6e38ab8

Browse files
committed
Avoid exceptions from MySQL when searching for non-ASCII draft names/WG acronyms/etc.
- Legacy-Id: 1991
1 parent edb50ac commit 6e38ab8

4 files changed

Lines changed: 19 additions & 0 deletions

File tree

ietf/idindex/testurl.list

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
200 /drafts/?first_name=joe
2424
200 /drafts/?other_group=irtf
2525
200 /drafts/?wg_id=1682
26+
200 /drafts/?filename=%EF%BD%8C #non-ASCII
2627
200,heavy /drafts/_test/all_id.txt
2728
200,heavy /drafts/_test/id_index.txt
2829
200,heavy /drafts/_test/id_abstracts.txt

ietf/idindex/views.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,14 @@ def search(request):
151151
if key in args:
152152
searching = True
153153
if searching:
154+
# Non-ASCII strings don't match anything; this check
155+
# is currently needed to avoid complaints from MySQL.
156+
for k in ['filename','last_name','first_name']:
157+
try:
158+
tmp = str(args.get(k, ''))
159+
except:
160+
args[k] = '*NOSUCH*'
161+
154162
# '0' and '-1' are flag values for "any"
155163
# in the original .cgi search page.
156164
# They are compared as strings because the

ietf/idtracker/testurl.list

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
200,heavy /idtracker/?sub_state_id=6
2424
200 /idtracker/?search_area_acronym=1260
2525
200 /idtracker/?search_group_acronym=tls
26+
200 /idtracker/?search_group_acronym=%EF%BD%8C #non-ASCII
27+
200 /idtracker/?search_filename=%EF%BD%8C #non-ASCII
2628
200 /feed/last-call/
2729

2830
# An RFC with no matching value in InternetDrafts. This tests

ietf/idtracker/views.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,14 @@ def search(request):
5656
if form.is_valid() == False:
5757
searching = False
5858
if searching:
59+
# Non-ASCII group/filename doesn't match anything; this check
60+
# is currently needed to avoid complaints from MySQL.
61+
for k in ['search_group_acronym','search_filename']:
62+
try:
63+
tmp = str(args.get(k, ''))
64+
except:
65+
args[k] = '*NOSUCH*'
66+
5967
group = args.get('search_group_acronym', '')
6068
if group != '':
6169
rfclist = [rfc['rfc_number'] for rfc in Rfc.objects.all().filter(group_acronym=group).values('rfc_number')]

0 commit comments

Comments
 (0)