From ee2950cd1979e7f5fdc6d5df43d83d0a6a0ce5dc Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Fri, 25 May 2012 18:10:31 -0700 Subject: Fix a crashing bug when replacing text in a flow with unicode bodies. --- test/test_flow.py | 5 +++++ test/test_utils.py | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'test') diff --git a/test/test_flow.py b/test/test_flow.py index 627d9cd0..0b7fee4f 100644 --- a/test/test_flow.py +++ b/test/test_flow.py @@ -259,6 +259,11 @@ class uFlow(libpry.AutoTree): f = flow.Flow(None) f.request = tutils.treq() + def test_replace_unicode(self): + f = tutils.tflow_full() + f.response.content = "\xc2foo" + f.replace("foo", u"bar") + def test_replace(self): f = tutils.tflow_full() f.request.headers["foo"] = ["foo"] diff --git a/test/test_utils.py b/test/test_utils.py index f279ce65..8bff0303 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -175,8 +175,13 @@ class u_cleanBin(libpry.AutoTree): assert utils.cleanBin("\nne", True) == ".ne" +class u_safe_subn(libpry.AutoTree): + def test_simple(self): + assert utils.safe_subn("foo", u"bar", "\xc2foo") + tests = [ + u_safe_subn(), u_cleanBin(), u_parse_content_type(), uformat_timestamp(), -- cgit v1.2.3