summaryrefslogtreecommitdiff
path: root/src/sp_cookie_encryption.c
diff options
context:
space:
mode:
authorjvoisin2025-08-31 16:05:44 +0200
committerjvoisin2025-09-01 13:49:08 +0200
commitee5e383c6bbca94d5f93134510468b3fe87a470c (patch)
treef18914001702afe16a0fc1be7d08087447055d6b /src/sp_cookie_encryption.c
parent1c7598c432551d0c49c2c57f249ccd5ccabce638 (diff)
Add support for PHP8.5
Diffstat (limited to 'src/sp_cookie_encryption.c')
-rw-r--r--src/sp_cookie_encryption.c23
1 files changed, 21 insertions, 2 deletions
diff --git a/src/sp_cookie_encryption.c b/src/sp_cookie_encryption.c
index c833f94..ec5c7c2 100644
--- a/src/sp_cookie_encryption.c
+++ b/src/sp_cookie_encryption.c
@@ -48,7 +48,11 @@ static zend_string *encrypt_data(zend_string *data) {
48#if PHP_VERSION_ID >= 70300 48#if PHP_VERSION_ID >= 70300
49static void php_head_parse_cookie_options_array( 49static void php_head_parse_cookie_options_array(
50 zval *options, zend_long *expires, zend_string **path, zend_string **domain, 50 zval *options, zend_long *expires, zend_string **path, zend_string **domain,
51 zend_bool *secure, zend_bool *httponly, zend_string **samesite) { 51 zend_bool *secure, zend_bool *httponly, zend_string **samesite
52#if PHP_VERSION_ID >= 80500
53 ,bool *partitioned
54#endif
55 ) {
52 int found = 0; 56 int found = 0;
53 zend_string *key; 57 zend_string *key;
54 zval *value; 58 zval *value;
@@ -73,6 +77,11 @@ static void php_head_parse_cookie_options_array(
73 } else if (zend_string_equals_literal_ci(key, "samesite")) { 77 } else if (zend_string_equals_literal_ci(key, "samesite")) {
74 *samesite = zval_get_string(value); 78 *samesite = zval_get_string(value);
75 found++; 79 found++;
80#if PHP_VERSION_ID >= 80500
81 } else if (zend_string_equals_literal_ci(key, "partitioned")) {
82 *partitioned = zval_is_true(value);
83 found++;
84#endif
76 } else { 85 } else {
77 php_error_docref(NULL, E_WARNING, 86 php_error_docref(NULL, E_WARNING,
78 "Unrecognized key '%s' found in the options array", 87 "Unrecognized key '%s' found in the options array",
@@ -94,6 +103,9 @@ static void php_head_parse_cookie_options_array(
94#endif 103#endif
95 104
96PHP_FUNCTION(sp_setcookie) { 105PHP_FUNCTION(sp_setcookie) {
106#if PHP_VERSION_ID >= 80500
107 zend_bool partitioned;
108#endif
97 zend_string *name = NULL, *value = NULL, *path = NULL, *domain = NULL, 109 zend_string *name = NULL, *value = NULL, *path = NULL, *domain = NULL,
98 *value_enc = NULL, 110 *value_enc = NULL,
99#if PHP_VERSION_ID < 70300 111#if PHP_VERSION_ID < 70300
@@ -133,7 +145,11 @@ PHP_FUNCTION(sp_setcookie) {
133 } 145 }
134 php_head_parse_cookie_options_array(expires_or_options, &expires, &path, 146 php_head_parse_cookie_options_array(expires_or_options, &expires, &path,
135 &domain, &secure, &httponly, 147 &domain, &secure, &httponly,
148#if PHP_VERSION_ID < 80500
136 &samesite); 149 &samesite);
150#else
151 &samesite, &partitioned);
152#endif
137 } else { 153 } else {
138 expires = zval_get_long(expires_or_options); 154 expires = zval_get_long(expires_or_options);
139 } 155 }
@@ -194,9 +210,12 @@ PHP_FUNCTION(sp_setcookie) {
194 if (php_setcookie(name, (value_enc ? value_enc : value), expires, 210 if (php_setcookie(name, (value_enc ? value_enc : value), expires,
195 (path_samesite ? path_samesite : path), domain, secure, 1, 211 (path_samesite ? path_samesite : path), domain, secure, 1,
196 httponly) == SUCCESS) { 212 httponly) == SUCCESS) {
197#else 213#elif PHP_VERSION_ID < 80500
198 if (php_setcookie(name, (value_enc ? value_enc : value), expires, path, 214 if (php_setcookie(name, (value_enc ? value_enc : value), expires, path,
199 domain, secure, httponly, samesite, 1) == SUCCESS) { 215 domain, secure, httponly, samesite, 1) == SUCCESS) {
216#else
217 if (php_setcookie(name, (value_enc ? value_enc : value), expires, path,
218 domain, secure, httponly, samesite, partitioned, false) == SUCCESS) {
200#endif 219#endif
201 RETVAL_TRUE; 220 RETVAL_TRUE;
202 } else { 221 } else {