Skip to content

Commit

Permalink
utf8 is accepted like if it was utf-8
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Jan 23, 2025
1 parent 2742960 commit c46ee5c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions sources/MVCFramework.Commons.pas
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ TMVCCharSet = record
ISO88598 = 'ISO-8859-8';
ISO885915 = 'ISO-8859-15';
UTF_8 = 'UTF-8';
UTF_8_WITHOUT_DASH = 'UTF8'; {this is wrong, but it is a quite common notation}
UTF_16 = 'UTF-16';
UTF_16BE = 'UTF-16BE';
UTF_16LE = 'UTF-16LE';
Expand Down
6 changes: 4 additions & 2 deletions sources/MVCFramework.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1564,16 +1564,18 @@ function TMVCWebRequest.Body: string;
begin
if (FBody = EmptyStr) then
begin
if (FCharset = EmptyStr) or (SameText(FCharset, TMVCCharSet.UTF_8)) then
if (FCharset = EmptyStr) or SameText(FCharset, TMVCCharSet.UTF_8) or SameText(FCharset, TMVCCharSet.UTF_8_WITHOUT_DASH) then
begin
lFreeEncoding := False;
FCharset := TMVCCharSet.UTF_8;
lEncoding := gEncodingUTF8; //utf-8 is the most used encoding, we have a global instance
end
else
begin
lFreeEncoding := True;
lEncoding := TEncoding.GetEncoding(FCharset);
end;

try
{$IF Defined(BERLINORBETTER)}
FWebRequest.ReadTotalContent; // Otherwise ISAPI Raises "Empty BODY"
Expand Down Expand Up @@ -4390,7 +4392,7 @@ procedure TMVCRenderer.Render(const AContent: string);
var
lOutEncoding: TEncoding;
begin
if SameText('UTF-8', FContentCharset) then
if SameText(TMVCCharSet.UTF_8, FContentCharset) or SameText(TMVCCharSet.UTF_8_WITHOUT_DASH, FContentCharset) then
begin
GetContext
.Response
Expand Down

0 comments on commit c46ee5c

Please sign in to comment.