From efc5ef502bc1ca75ad68c0870f245bfb622c5869 Mon Sep 17 00:00:00 2001 From: mattias Date: Sun, 28 Feb 2021 22:39:58 +0000 Subject: [PATCH] lazutils: UTF8BOMToUTF8: sanity check git-svn-id: trunk@64700 - --- components/lazutils/lconvencoding.pas | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/components/lazutils/lconvencoding.pas b/components/lazutils/lconvencoding.pas index aaed6b8c53..2791c5ae55 100644 --- a/components/lazutils/lconvencoding.pas +++ b/components/lazutils/lconvencoding.pas @@ -358,7 +358,11 @@ end; function UTF8BOMToUTF8(const s: string): string; begin - Result:=copy(s,4,length(s)); + if s='' then exit(''); + if CompareMem(@UTF8BOM[1],@s[1],length(UTF8BOM)) then + Result:=copy(s,4,length(s)) + else + Result:=s; end; function ISO_8859_1ToUTF8(const s: string): string;