diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-05-25 18:10:31 -0700 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-05-25 18:10:31 -0700 |
commit | ee2950cd1979e7f5fdc6d5df43d83d0a6a0ce5dc (patch) | |
tree | f23ec4f984f9b15a8ce656113bf17c4cfa0f8d7b /libmproxy/flow.py | |
parent | a0c63b6108e76d24222b51def69c74fb88d72b0c (diff) | |
download | mitmproxy-ee2950cd1979e7f5fdc6d5df43d83d0a6a0ce5dc.tar.gz mitmproxy-ee2950cd1979e7f5fdc6d5df43d83d0a6a0ce5dc.tar.bz2 mitmproxy-ee2950cd1979e7f5fdc6d5df43d83d0a6a0ce5dc.zip |
Fix a crashing bug when replacing text in a flow with unicode bodies.
Diffstat (limited to 'libmproxy/flow.py')
-rw-r--r-- | libmproxy/flow.py | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/libmproxy/flow.py b/libmproxy/flow.py index 2258868b..6b3d868e 100644 --- a/libmproxy/flow.py +++ b/libmproxy/flow.py @@ -249,9 +249,9 @@ class ODict: """ nlst, count = [], 0 for i in self.lst: - k, c = re.subn(pattern, repl, i[0], *args, **kwargs) + k, c = utils.safe_subn(pattern, repl, i[0], *args, **kwargs) count += c - v, c = re.subn(pattern, repl, i[1], *args, **kwargs) + v, c = utils.safe_subn(pattern, repl, i[1], *args, **kwargs) count += c nlst.append([k, v]) self.lst = nlst @@ -560,8 +560,8 @@ class Request(HTTPMsg): Returns the number of replacements made. """ with decoded(self): - self.content, c = re.subn(pattern, repl, self.content, *args, **kwargs) - self.path, pc = re.subn(pattern, repl, self.path, *args, **kwargs) + self.content, c = utils.safe_subn(pattern, repl, self.content, *args, **kwargs) + self.path, pc = utils.safe_subn(pattern, repl, self.path, *args, **kwargs) c += pc c += self.headers.replace(pattern, repl, *args, **kwargs) return c @@ -740,7 +740,7 @@ class Response(HTTPMsg): Returns the number of replacements made. """ with decoded(self): - self.content, c = re.subn(pattern, repl, self.content, *args, **kwargs) + self.content, c = utils.safe_subn(pattern, repl, self.content, *args, **kwargs) c += self.headers.replace(pattern, repl, *args, **kwargs) return c @@ -869,7 +869,7 @@ class Error(controller.Msg): FIXME: Is replace useful on an Error object?? """ - self.msg, c = re.subn(pattern, repl, self.msg, *args, **kwargs) + self.msg, c = utils.safe_subn(pattern, repl, self.msg, *args, **kwargs) return c |