View Issue Details

IDProjectCategoryView StatusLast Update
0036679LazarusIDEpublic2020-03-21 13:44
ReporterSven BarthAssigned ToBart Broersma 
Status resolvedResolutionfixed 
PlatformX86_64OSWindows NTOS Version10
Product Version2.1 (SVN)Product Build62608 
Target VersionFixed in Version2.0.8 
Summary0036679: Lazarus detects file with a long, first line as "binary"
DescriptionWhen opening a "HTML resource" file as generated by pas2js which might contain long lines Lazarus might detect these files as non-binary because there's no newline during the first 1024 Byte. If this file is kept open upon recompilations then it's especially annoying as not only there's the "file was changed" dialog (*), but also this "file might not be text" dialog.

(*) Using the "use contents instead of time stamp" option improves this at least as long as nothing changed
Steps To Reproduce- open the attached file in Lazarus
- notice the "file might not be text" dialog
TagsNo tags attached.
Fixed in Revisionr62787
Attached Files


Sven Barth

2020-02-07 23:19


tp2j-res.html (3,271 bytes)

Bart Broersma

2020-02-08 00:15

developer   ~0120933

Last edited: 2020-02-08 00:21

View 3 revisions

FileIsText maybe should only exit false if it finds a character of which we are sure is not text.
What are the chances you don't find an "offending" byte in a binary file within 1024 bytes?

I have a GetTextFileType function that uses that approach and that says the offending file is of type tftASCII.

Sven Barth

2020-02-08 18:56

manager   ~0120949

I personally agree with that assumption.

Bart Broersma

2020-02-08 19:31

developer   ~0120952

Last edited: 2020-02-08 19:31

View 2 revisions

The code also allows for malformed Unicode (Utf8, Utf16LE and Utf16BE) text.
I.e. a file with UTF8 BOM and then one Chr(10) and after that only $FF will result in the functon returning True .
(My GetTextFileType will return tftUnknown)

Bart Broersma

2020-03-01 14:21

developer   ~0121294

I would propose to skip the test for NewLine and increase the buffer to 2048.
This should catch most cases of non-text files.

Bart Broersma

2020-03-21 13:42

developer   ~0121672

Fixed as proposed.
Please test and close if OK.

Issue History

Date Modified Username Field Change
2020-02-07 23:19 Sven Barth New Issue
2020-02-07 23:19 Sven Barth File Added: tp2j-res.html
2020-02-08 00:15 Bart Broersma Note Added: 0120933
2020-02-08 00:21 Bart Broersma Note Edited: 0120933 View Revisions
2020-02-08 00:21 Bart Broersma Note Edited: 0120933 View Revisions
2020-02-08 18:56 Sven Barth Note Added: 0120949
2020-02-08 19:31 Bart Broersma Note Added: 0120952
2020-02-08 19:31 Bart Broersma Note Edited: 0120952 View Revisions
2020-03-01 14:21 Bart Broersma Note Added: 0121294
2020-03-21 13:42 Bart Broersma Assigned To => Bart Broersma
2020-03-21 13:42 Bart Broersma Status new => resolved
2020-03-21 13:42 Bart Broersma Resolution open => fixed
2020-03-21 13:42 Bart Broersma Fixed in Version => 2.0.8
2020-03-21 13:42 Bart Broersma Fixed in Revision => r62787
2020-03-21 13:42 Bart Broersma LazTarget => 2.0.8
2020-03-21 13:42 Bart Broersma Widgetset Win32/Win64 => Win32/Win64
2020-03-21 13:42 Bart Broersma Note Added: 0121672