fix out of range error in tracker remover plugin

This commit is contained in:
Marc Abonce Seguin 2019-10-22 23:17:00 -07:00
parent 12f42d1572
commit dede46a2d5
1 changed files with 5 additions and 7 deletions

View File

@ -39,16 +39,14 @@ def on_result(request, search, result):
return True return True
parsed_query = parse_qsl(query) parsed_query = parse_qsl(query)
changed = False changes = 0
for i, (param_name, _) in enumerate(list(parsed_query)): for i, (param_name, _) in enumerate(list(parsed_query)):
for reg in regexes: for reg in regexes:
if reg.match(param_name): if reg.match(param_name):
parsed_query.pop(i) parsed_query.pop(i - changes)
changed = True changes += 1
result['parsed_url'] = result['parsed_url']._replace(query=urlencode(parsed_query))
result['url'] = urlunparse(result['parsed_url'])
break break
if changed:
result['parsed_url'] = result['parsed_url']._replace(query=urlencode(parsed_query))
result['url'] = urlunparse(result['parsed_url'])
return True return True