Skip to content
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

Fix not showing full file content when there is a NULL character in the middle of the file #216

Closed
wants to merge 1 commit into from
Closed

Fix not showing full file content when there is a NULL character in the middle of the file #216

wants to merge 1 commit into from

Conversation

validatedev
Copy link
Contributor

@validatedev validatedev commented Oct 1, 2019

Fixes #200
Co-authored-by: M. Şamil Ateşoğlu [email protected]

…he middle of the file.

Co-authored-by: M. Şamil Ateşoğlu <[email protected]>
@0x7c13
Copy link
Owner

0x7c13 commented Oct 1, 2019

I am not sure if we can simply remove it from the string. That means, when we save the file, the null character will be gone right?

@0x7c13
Copy link
Owner

0x7c13 commented Oct 1, 2019

Take a look at last comment in this thread: https://www.c-sharpcorner.com/forums/how-to-write-null-character-in-textbox

@validatedev
Copy link
Contributor Author

validatedev commented Oct 1, 2019

I think that the problem is the bug which is located on RichEditBox. It should display the file until encountering the EOF. Let me explain with details:

text = reader.ReadToEnd();

That implementation of reading the file is true and works as intended. It reads and passes the "\0" character, not stops there. But the built-in tool on the Visual Studio that shows the content what the variable has encounters the same error doesn't show the file content after the "\0" character. FileInput and string are not the same thing. The built-in tool and the RichEditBox also behave to file like a just the string. Let me explain with photos:

Before the changes
1
2

After the changes
3
4

And good news, our implementation works correctly without any problem. It doesn't change the string "\0", just the character one. Also you can try to change RichEditBox thing to display characters correctly but it's just up to you.

@0x7c13
Copy link
Owner

0x7c13 commented Oct 1, 2019

Yes, I know it works from reading to representation. I am more concerned about file saving. Did you try open the file and save it? Then take a look if \0 is missing in the output file?

@validatedev
Copy link
Contributor Author

validatedev commented Oct 1, 2019

Yes, I know it works from reading to representation. I am more concerned about file saving. Did you try open the file and save it? Then take a look if \0 is missing in the output file?

It is gone from the file but I don't think that is the problem. Also it can surpass the errors that may happen in the future.

And one last note: If you don't want to delete \0, you should look at the behaviour of the RichEditBox. If you can change that thing with their superior, it will definitely more accurate solution than this implementation but I can't see any harm with that.

@0x7c13
Copy link
Owner

0x7c13 commented Oct 1, 2019

Yes, I know it works from reading to representation. I am more concerned about file saving. Did you try open the file and save it? Then take a look if \0 is missing in the output file?

It is gone from the file but I don't think that is the problem. Also it can surpass the errors that may happen in the future.

And one last note: If you don't want to delete \0, you should look at the behaviour of the RichEditBox. If you can change that thing with their superior, it will definitely more accurate solution than this implementation but I can't see any harm with that.

No, actually it is a problem, because if the file is intended to have "\0" and it is accepted by another program, then it will cause unwanted behavior. Let me think about it and see what we can do here.

@0x7c13
Copy link
Owner

0x7c13 commented Oct 5, 2019

At least, we can(should) let the user know if the file opening has a null character and let the user decide what to do (ignore or remove it).

@validatedev
Copy link
Contributor Author

Ok then I'll close that pull req and try to apply the solution that you're referring to.

@validatedev validatedev closed this Oct 5, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Bug] Cannot read the Bitlocker recovery key text file properly
2 participants