mirror of
https://github.com/Grasscutters/mitmproxy.git
synced 2025-01-31 07:18:58 +00:00
fix strutils.split_special_areas
This commit is contained in:
parent
1000efb671
commit
e1af76e71f
@ -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
|
||||
)
|
||||
|
||||
|
||||
|
@ -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():
|
||||
|
Loading…
Reference in New Issue
Block a user