Skip to content

Commit cb3669f

Browse files
committed
bugfix
1 parent e470d45 commit cb3669f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

refinery/units/encoding/esc.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ class esc(Unit):
1111
Encodes and decodes common ASCII escape sequences.
1212
"""
1313
_ESCAPE = {
14-
0x00: BR'\0',
1514
0x07: BR'\a',
1615
0x08: BR'\b',
1716
0x0C: BR'\f',
@@ -93,7 +92,7 @@ def unescape(match: re.Match[bytes]):
9392
RB'\\(u[a-fA-F0-9]{4}|x[a-fA-F0-9]{1,2}|[0-7]{1,3}|.)', unescape, data)
9493
return data
9594

96-
def reverse(self, data):
95+
def reverse(self, data: bytearray):
9796
if self.args.unicode:
9897
string = data.decode(self.codec).encode('UNICODE_ESCAPE')
9998
else:

test/units/encoding/test_esc.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,3 +113,8 @@ def test_regression_sneaky2fa_user_agents(self):
113113
goal = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36'
114114
test = data | self.load() | str
115115
self.assertEqual(goal, test)
116+
117+
def test_invertible_with_zero_bytes(self):
118+
data = B'FOO\x005BAR'
119+
test = data | -self.load() | self.load() | bytes
120+
self.assertEqual(test, data)

0 commit comments

Comments
 (0)