-
-
Notifications
You must be signed in to change notification settings - Fork 45
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
file containing null byte causes crash #251
Comments
it should probably just reject these files -- similar to what it does for non-UTF-8 files |
it only comes up when trying to render the char, so opening the file with @pytest.mark.parametrize('s', (b'\x00', b'\n' * 81 + b'\x00'))
def test_file_contains_zero_bytes(s, run, tmpdir):
f = tmpdir.join('f')
f.write_binary(s)
with run(str(f)) as h, and_exit(h):
h.press('a')
h.await_text('*')
h.press('^S')
h.await_text('saved!')
# h.await_text('error! zero byte found:') It should probably display an error message like for non utf-8 files. So how can we catch this earlier, like when opening instead of when it's rendered? somewhere in |
here's where the other errors are checked: Lines 67 to 75 in 511de75
|
reproduction
Traceback:
Versions:
characters like
\x01
or\x02
work fine and are displayed as^A
or^B
context
I encountered this error while trying to open and fix a somewhat corrupted file. While python was writing to this file, the machine crashed and a bunch of null bytes ended up at the end of the file, removing them makes the file usable again.
nano
,less
andvim
display\x00
as^@
.The text was updated successfully, but these errors were encountered: