aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaximilian Hils <git@maximilianhils.com>2017-08-26 17:04:56 +0200
committerMaximilian Hils <git@maximilianhils.com>2017-08-26 17:04:56 +0200
commite1af76e71f6b2230847767c0bbccdc40fd98bb3b (patch)
treedc7a6ac2dfff6072f0591d7e8fd4305c6c9707f9
parent1000efb67110769ca91b3e87057dd39c73c5dbd6 (diff)
downloadmitmproxy-e1af76e71f6b2230847767c0bbccdc40fd98bb3b.tar.gz
mitmproxy-e1af76e71f6b2230847767c0bbccdc40fd98bb3b.tar.bz2
mitmproxy-e1af76e71f6b2230847767c0bbccdc40fd98bb3b.zip
fix strutils.split_special_areas
-rw-r--r--mitmproxy/utils/strutils.py4
-rw-r--r--test/mitmproxy/utils/test_strutils.py8
2 files changed, 10 insertions, 2 deletions
diff --git a/mitmproxy/utils/strutils.py b/mitmproxy/utils/strutils.py
index 1a4b5bb2..37bed7de 100644
--- a/mitmproxy/utils/strutils.py
+++ b/mitmproxy/utils/strutils.py
@@ -172,14 +172,14 @@ def split_special_areas(
"".join(split_special_areas(x, ...)) == x always holds true.
"""
patterns = "|".join(
- r"{lchar}.*?{rchar}".format(
+ r"{lchar}[\s\S]*?{rchar}".format(
lchar=a,
rchar=b,
) for (a, b) in area_delimiter)
return re.split(
"({})".format(patterns),
data,
- re.MULTILINE
+ flags=re.MULTILINE
)
diff --git a/test/mitmproxy/utils/test_strutils.py b/test/mitmproxy/utils/test_strutils.py
index ea3569c0..7ec72e4e 100644
--- a/test/mitmproxy/utils/test_strutils.py
+++ b/test/mitmproxy/utils/test_strutils.py
@@ -111,6 +111,14 @@ def test_split_special_areas():
"""foo 'b\\'a"r' baz""",
ESCAPE_QUOTES
) == ["foo ", "'b\\'a\"r'", " baz"]
+ assert strutils.split_special_areas(
+ "foo\n/*bar\nbaz*/\nqux",
+ [(r'/\*', r'\*/')]
+ ) == ["foo\n", "/*bar\nbaz*/", "\nqux"]
+ assert strutils.split_special_areas(
+ "foo\n//bar\nbaz",
+ [(r'//', r'$')]
+ ) == ["foo\n", "//bar", "\nbaz"]
def test_escape_special_areas():