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

Notepad3 exe opened in NP3 does not show uniform line endings... #1198

Closed
MelchiorGaspar opened this issue May 12, 2019 · 14 comments
Closed

Comments

@MelchiorGaspar
Copy link
Contributor

While exploring files with unknown file extensions (exe, dll, or no extension at all)
I opened Notepad 3 exe in Notepad 3 and found that the line endings of the Notepad 3 exe are NOT UNIFORM... is this the way its supposed to be? I mean NP3 does run and exit fine... is this an issue?

Notepad 3__exe line endings not uniform

@MelchiorGaspar MelchiorGaspar changed the title Notepad3 exe opened in NP3 does not show uniform line endings... issue? [Question, bug, or compiler issue?] Notepad3 exe opened in NP3 does not show uniform line endings... May 12, 2019
@RaiKoHoff
Copy link
Collaborator

Maybe it makes sense to suppress consistency checks for line-breaks and indentation while loading files with unknown file extensions 🤔

@hpwamr
Copy link
Collaborator

hpwamr commented May 12, 2019

I think, it makes certainly sense if the user try to open binaries files (.exe, .dll, etc...) 🤔

@MelchiorGaspar
Copy link
Contributor Author

lol ok if that's what you guys want to do...
I was trying to find out if NP3 and other programs.. is it normal to have different line breaks in an exe?
and still be considered a Windows program? shouldn't they all be CR+LF

@RaiKoHoff
Copy link
Collaborator

Of cause, you will have different line-breaks in binary files.
I think it is a valid workflow to check inconsistent line-breaks and indentation for well known file-extensions only. (You are free to add file-extensions to the lexers you want, to make them "known").

Please test beta version _5.19.512.1699_RC (see beta-channel access #1129).

@RaiKoHoff RaiKoHoff changed the title [Question, bug, or compiler issue?] Notepad3 exe opened in NP3 does not show uniform line endings... Notepad3 exe opened in NP3 does not show uniform line endings... May 12, 2019
@garoto
Copy link

garoto commented May 12, 2019

Binary files don't have line-endings.

@MelchiorGaspar
Copy link
Contributor Author

@RaiKoHoff ok... why is that? why can or do they have different line endings?
do you know why?

@garoto why is that?

@garoto
Copy link

garoto commented May 12, 2019

@garoto why is that?

Because once you compile source code it becomes CPU machine code, and a CPU only cares about the byte stream.

The fact that you will find CR+LF or LF or CR only chars once you open a binary file on a text editor is expected and those do not represent your usual newline chars you see on your regular ASCII file, they are simply binary data translated to HEX code and then interpreted as is. Ever heard your computer speaker beeping once you dumped the contents of a binay file to your computer terminal/cmd.exe by mistake?

You should use a HEX editor to peruse file data that is not pure ASCII.

https://en.wikipedia.org/wiki/Newline
https://en.wikipedia.org/wiki/Compiler

@hpwamr
Copy link
Collaborator

hpwamr commented May 12, 2019

Maybe it makes sense to suppress consistency checks for line-breaks and indentation while loading files with unknown file extensions 🤔

I think, it makes certainly sense if the user try to open binaries files (.exe, .dll, etc...) 🤔

Hello @RaiKoHoff ,
I may have expressed myself poorly, but it would seem normal that consistency checks for line-breaks and indentation would be disabled in all cases of binary files.

An example with: Encryption/Descrypt File (I think that there is really no valid reason that the dialog box "Inconsistent Line Endings" is triggered):

2019-05-12_192302
2019-05-12_191951

2019-05-12_192125

@MelchiorGaspar
Copy link
Contributor Author

@garoto thx for the explanation..
I use XVI32 for a HexEditor...

@RaiKoHoff
Copy link
Collaborator

Sorry for my "careless" answer ("line-breaks in binary files"). @garoto gave a good answer.
If you don't have a file-extension, which is also only a hint to what kind of file to expect, you have to analyze the byte-stream you are going to read.
Notepad3 needs to guess an encoding to interpret bytes and multi-byte combinations to translate it into sensible information.
Some files have a Signature (UTF-8-Sig, NP3-Encrypted) or Byte-Order-Mark(BOM) (UTF-16LE/BE) at the beginning of the file to identify the encoding, some others don't have (ASCII, ANSI). This is where the encoding-detector jumps in to identify the encoding (assuming it is a text-document).
It is not easy to distinguish between a pure binary byte-stream and a (unknown) text-encoding byte-stream (some text are senseless too, so they can be assumed as binary noise 😉).
We have to rely on some heuristics to skip the (senseless) inconsistency checks:

  • missing or unknown file-extensions (I think this is OK)
  • encrypted raw data
  • (binary type detection result of the encoding detector
    (don't know if there is something - have to check)
  • maybe a (configurable) black-list of file-extensions to exclude:, e.g.: exe; zip; (to be implemented)
  • ... ???

@zufuliu
Copy link

zufuliu commented May 13, 2019

Something might help: zufuliu/notepad4@9e21ee1 and zufuliu/notepad4@f676095

The unreliable Style_MaybeBinaryFile() is not enabled.

@RaiKoHoff
Copy link
Collaborator

Please test development beta version _5.19.514.1702_RC
(Beta Channel: see #1129).
This version has a rudimentary binary file detection (implementation provided by @zufuliu - thanx) plus some heuristic rules to avoid unnecessary/non-sensible inconsistency checks.

@MelchiorGaspar
Copy link
Contributor Author

MelchiorGaspar commented May 14, 2019

ok, I will test it when I get home from food shopping a little later..
EDIT:
it seems to work fine.. no crashing... so.. idk what else I can look for...

@hpwamr
Copy link
Collaborator

hpwamr commented Sep 27, 2019

Hello @MelchiorGaspar ,
As far as I'm concerned, I think you (as requester) can close this issue...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants