From 039fa1c3b59a61fefd9fda33b2ceec97fbedd7f1 Mon Sep 17 00:00:00 2001 From: geby Date: Sat, 12 Jun 2021 16:29:06 +0000 Subject: [PATCH] Fix MIME bug #26 (Pierre le Riche) git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@222 7c85be65-684b-0410-a082-b2ed4fbef004 --- mimemess.pas | 2 +- mimepart.pas | 8 ++++++-- synachar.pas | 37 +++++++++++++++++++++++++++++++------ 3 files changed, 38 insertions(+), 9 deletions(-) diff --git a/mimemess.pas b/mimemess.pas index cf690c1..e90cfb0 100644 --- a/mimemess.pas +++ b/mimemess.pas @@ -640,7 +640,7 @@ begin Secondary := 'plain'; Description := 'Message text'; Disposition := 'inline'; - CharsetCode := IdealCharsetCoding(Value.Text, TargetCharset, IdealCharsets); + CharsetCode := IdealCharsetCoding(AnsiString(Value.Text), TargetCharset, IdealCharsets); EncodingCode := ME_QUOTED_PRINTABLE; EncodePart; EncodePartHeader; diff --git a/mimepart.pas b/mimepart.pas index 823919b..b5b7a98 100644 --- a/mimepart.pas +++ b/mimepart.pas @@ -966,7 +966,11 @@ end; procedure TMIMEPart.EncodePart; var l: TStringList; - s, t: string; +{$IFDEF UNICODE} + s, t: RawByteString; +{$ELSE} + s, t: string; +{$ENDIF} n, x: Integer; d1, d2: integer; begin @@ -1076,7 +1080,7 @@ begin FHeaders.Insert(0, 'Content-Disposition: ' + LowerCase(FDisposition) + s); end; if FContentID <> '' then - FHeaders.Insert(0, 'Content-ID: ' + FContentID); + FHeaders.Insert(0, 'Content-ID: <' + FContentID + '>'); case FEncodingCode of ME_7BIT: diff --git a/synachar.pas b/synachar.pas index dd167ab..e9e4f31 100644 --- a/synachar.pas +++ b/synachar.pas @@ -1,5 +1,5 @@ {==============================================================================| -| Project : Ararat Synapse | 005.002.004 | +| Project : Ararat Synapse | 005.002.005 | |==============================================================================| | Content: Charset conversion support | |==============================================================================| @@ -1744,15 +1744,40 @@ begin Result := ''; case Value of UCS_2: - Result := #$fe + #$ff; + begin + SetLength(Result, 2); + Result[1] := #$fe; + Result[2] := #$ff; + end; UCS_4: - Result := #$00 + #$00 + #$fe + #$ff; + begin + SetLength(Result, 4); + Result[1] := #$00; + Result[2] := #$00; + Result[3] := #$fe; + Result[4] := #$ff; + end; UCS_2LE: - Result := #$ff + #$fe; + begin + SetLength(Result, 2); + Result[1] := #$ff; + Result[2] := #$fe; + end; UCS_4LE: - Result := #$ff + #$fe + #$00 + #$00; + begin + SetLength(Result, 4); + Result[1] := #$ff; + Result[2] := #$fe; + Result[3] := #$00; + Result[4] := #$00; + end; UTF_8: - Result := #$ef + #$bb + #$bf; + begin + SetLength(Result, 3); + Result[1] := #$ef; + Result[2] := #$bb; + Result[3] := #$bf; + end; end; end;