View Issue Details

IDProjectCategoryView StatusLast Update
0036679LazarusIDEpublic2020-02-08 19:32
ReporterSven BarthAssigned To 
PrioritynormalSeverityminorReproducibilityalways
Status newResolutionopen 
PlatformX86_64OSWindows NTOS Version10
Product Version2.1 (SVN)Product Build62608 
Target VersionFixed in Version 
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 Revision
LazTarget
WidgetsetWin32/Win64
Attached Files

Activities

Sven Barth

2020-02-07 23:19

manager  

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)

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