Skip to content

Commit 1ab44ec

Browse files
committed
Fix bug in TFileIO.CheckBOM (TStream overload)
Method was returning True for encodings with zero length BOMs instead of the False result per documentation. Fixes #139
1 parent bbdbdca commit 1ab44ec

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

Diff for: Src/UIOUtils.pas

+2
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,8 @@ class function TFileIO.CheckBOM(const Stream: TStream;
206206
Assert(Assigned(Stream), 'TFileIO.CheckBOM: Stream is nil');
207207
Assert(Assigned(Encoding), 'TFileIO.CheckBOM: Encoding is nil');
208208
Preamble := Encoding.GetPreamble;
209+
if Length(Preamble) = 0 then
210+
Exit(False);
209211
if Stream.Size < Length(Preamble) then
210212
Exit(False);
211213
OldPos := Stream.Position;

0 commit comments

Comments
 (0)