mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-16 17:19:32 +02:00
* Merging revisions r45446 from trunk:
------------------------------------------------------------------------ r45446 | michael | 2020-05-20 11:34:44 +0200 (Wed, 20 May 2020) | 1 line * Add support for SameSite attribute of cookie (bug ID 0037115) ------------------------------------------------------------------------ git-svn-id: branches/fixes_3_2@46588 -
This commit is contained in:
parent
0a2f57724b
commit
9ae60e491c
@ -97,6 +97,7 @@ const
|
||||
SCookiePath = httpProtocol.SCookiePath;
|
||||
SCookieSecure = httpProtocol.SCookieSecure;
|
||||
SCookieHttpOnly = httpProtocol.SCookieHttpOnly;
|
||||
SCookieSameSite = httpProtocol.SCookieSameSite;
|
||||
|
||||
HTTPMonths : array[1..12] of string[3] = (
|
||||
'Jan', 'Feb', 'Mar', 'Apr',
|
||||
@ -148,11 +149,13 @@ type
|
||||
TRequest = Class;
|
||||
|
||||
{ TCookie }
|
||||
TSameSite = (ssEmpty,ssNone,ssStrict,ssLax);
|
||||
|
||||
TCookie = class(TCollectionItem)
|
||||
private
|
||||
FHttpOnly: Boolean;
|
||||
FName: string;
|
||||
FSameSite: TSameSite;
|
||||
FValue: string;
|
||||
FPath: string;
|
||||
FDomain: string;
|
||||
@ -171,6 +174,7 @@ type
|
||||
property Expires: TDateTime read FExpires write FExpires;
|
||||
property Secure: Boolean read FSecure write FSecure;
|
||||
property HttpOnly: Boolean read FHttpOnly write FHttpOnly;
|
||||
property SameSite: TSameSite Read FSameSite Write FSameSite;
|
||||
Property AsString : String Read GetAsString;
|
||||
end;
|
||||
|
||||
@ -2317,6 +2321,10 @@ function TCookie.GetAsString: string;
|
||||
Result:=Result+';'+S;
|
||||
end;
|
||||
|
||||
Const
|
||||
SSameSiteValues : Array[TSameSite] of string
|
||||
= ('','None','Strict','Lax');
|
||||
|
||||
Var
|
||||
Y,M,D : Word;
|
||||
|
||||
@ -2338,6 +2346,8 @@ begin
|
||||
AddToResult(SCookieHttpOnly);
|
||||
if FSecure then
|
||||
AddToResult(SCookieSecure);
|
||||
if FSameSite<>ssEmpty then
|
||||
AddToResult(SSameSiteValues[FSameSite]);
|
||||
except
|
||||
{$ifdef cgidebug}
|
||||
On E : Exception do
|
||||
|
@ -87,6 +87,7 @@ Const
|
||||
SCookiePath = ' Path=%s';
|
||||
SCookieSecure = ' Secure';
|
||||
SCookieHttpOnly = ' HttpOnly';
|
||||
SCookieSameSite = ' SameSite';
|
||||
|
||||
HTTPMonths: array[1..12] of string[3] = (
|
||||
'Jan', 'Feb', 'Mar', 'Apr',
|
||||
|
Loading…
Reference in New Issue
Block a user