summaryrefslogtreecommitdiff
path: root/src/sp_config_keywords.c
diff options
context:
space:
mode:
authorBen Fuhrmannek2022-07-20 10:46:16 +0200
committerBen Fuhrmannek2022-07-20 10:46:16 +0200
commit72109c9bf016145364b19162a5ff998fc5858a9c (patch)
treecd71881776efc2f9aad1170405e55611105c3600 /src/sp_config_keywords.c
parent49e074c5914d4dd90d9c03394e5aa161c74f28ca (diff)
fixed cookie config parsing with same cookie name (update instead of ignore)
Diffstat (limited to 'src/sp_config_keywords.c')
-rw-r--r--src/sp_config_keywords.c23
1 files changed, 22 insertions, 1 deletions
diff --git a/src/sp_config_keywords.c b/src/sp_config_keywords.c
index c8922ae..c3ef24e 100644
--- a/src/sp_config_keywords.c
+++ b/src/sp_config_keywords.c
@@ -232,7 +232,28 @@ SP_PARSE_FN(parse_cookie) {
232 samesite = NULL; 232 samesite = NULL;
233 } 233 }
234 234
235 SPCFG(cookie).cookies = sp_list_insert(SPCFG(cookie).cookies, cookie); 235 // find other cookie entry with identical name or name_r
236 sp_cookie *entry = NULL;
237 sp_list_node *pList = NULL;
238 for (pList = SPCFG(cookie).cookies; pList; pList = pList->next) {
239 entry = pList->data;
240 if (!entry) { continue; }
241 if ((entry->name && cookie->name && sp_zend_string_equals(entry->name, cookie->name)) ||
242 (entry->name_r && cookie->name_r && sp_zend_string_equals(entry->name_r->pattern, cookie->name_r->pattern))) {
243 break;
244 }
245 }
246 if (pList && entry) {
247 // override cookie settings if set
248 if (cookie->samesite) { entry->samesite = cookie->samesite; }
249 if (cookie->encrypt) { entry->encrypt = cookie->encrypt; }
250 if (cookie->simulation) { entry->simulation = cookie->simulation; }
251 sp_free_cookie(cookie);
252 pefree(cookie, 1);
253 cookie = NULL;
254 } else {
255 SPCFG(cookie).cookies = sp_list_insert(SPCFG(cookie).cookies, cookie);
256 }
236 257
237 return SP_PARSER_STOP; 258 return SP_PARSER_STOP;
238 259