Fixes crash on illegal regular expression for interception.

This commit is contained in:
Thomas Roth 2010-02-24 23:59:54 +01:00
parent 0fc864c419
commit 6d41b27f53
2 changed files with 9 additions and 5 deletions

View File

@ -73,8 +73,10 @@ class FResp(_Action):
class _Rex(_Action): class _Rex(_Action):
def __init__(self, expr): def __init__(self, expr):
self.expr = expr self.expr = expr
try:
self.re = re.compile(self.expr) self.re = re.compile(self.expr)
except:
self.re = False
def _check_content_type(expr, o): def _check_content_type(expr, o):
val = o.headers.get("content-type") val = o.headers.get("content-type")
@ -186,7 +188,11 @@ class FUrl(_Rex):
def make(klass, s, loc, toks): def make(klass, s, loc, toks):
if len(toks) > 1: if len(toks) > 1:
toks = toks[1:] toks = toks[1:]
return klass(*toks) ret_klass = klass(*toks)
if ret_klass.re:
return ret_klass
else:
return False
def __call__(self, o): def __call__(self, o):
if o.is_response(): if o.is_response():

2
todo
View File

@ -14,7 +14,5 @@ Future:
Bugs: Bugs:
- Exception handling for regular expression compiler in filt.py.
- Fix crash on illegal regular expression on libmproxy/filt.py:76
- In some circumstances, long URLs in list view are line-broken oddly. - In some circumstances, long URLs in list view are line-broken oddly.
- Termination sometimes hangs. - Termination sometimes hangs.