Skip to content

Commit

Permalink
Fix tty_escape on Python 2
Browse files Browse the repository at this point in the history
  • Loading branch information
peace-maker committed Aug 7, 2024
1 parent 101f9bc commit de67c86
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions pwnlib/util/fiddling.py
Original file line number Diff line number Diff line change
Expand Up @@ -1114,12 +1114,12 @@ def tty_escape(s, lnext=b'\x16', dangerous=bytes(bytearray(range(0x20)))):
Returns:
The escaped data.
>>> tty_escape(b'abc\x04d\x18e')
b'abc\x16\x04d\x16\x18e'
>>> tty_escape(b'abc\x04d\x18e\x16f')
b'abc\x16\x04d\x16\x18e\x16\x16f'
"""
s = s.replace(lnext, lnext * 2)
for b in bytearray(dangerous):
b = bytes(bytearray([b]))
if b in lnext: continue
b = bytearray([b])
s = s.replace(b, lnext + b)
return s

0 comments on commit de67c86

Please sign in to comment.