From bb126da0fb49d1c9640eeb3371d0bbcf005bcd2b Mon Sep 17 00:00:00 2001 From: Thomas Pointhuber Date: Wed, 15 Oct 2014 14:47:03 +0200 Subject: [PATCH] improve https rewrite code --- searx/https_rewrite.py | 2 ++ searx/webapp.py | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/searx/https_rewrite.py b/searx/https_rewrite.py index 814eda2de..18405d87a 100644 --- a/searx/https_rewrite.py +++ b/searx/https_rewrite.py @@ -137,3 +137,5 @@ def load_https_rules(rules_path): # append ruleset https_rules.append(ruleset) + + print(' * {n} https-rules loaded'.format(n=len(https_rules))) diff --git a/searx/webapp.py b/searx/webapp.py index d9dc5f710..25c99d94c 100644 --- a/searx/webapp.py +++ b/searx/webapp.py @@ -224,10 +224,14 @@ def index(): # process rules for rule in rules: - # TODO, precompile rule - p = re.compile(rule[0]) - # rewrite url if possible - new_result_url = p.sub(rule[1], result['url']) + try: + # TODO, precompile rule + p = re.compile(rule[0]) + + # rewrite url if possible + new_result_url = p.sub(rule[1], result['url']) + except: + break # parse new url new_parsed_url = urlparse(new_result_url)