fix: use '+' delimiter for engines cookie to comply with RFC 6265

This commit is contained in:
frosty
2026-10-27 21:25:54 -04:00
parent 250898c638
commit 09e1f7e1ea
2 changed files with 24 additions and 3 deletions

View File

@@ -63,7 +63,7 @@ int settings_save_handler(UrlParams *params) {
size_t idlen = strlen(id); size_t idlen = strlen(id);
if (i > 0) { if (i > 0) {
if (used + 1 < sizeof(cookie_value)) { if (used + 1 < sizeof(cookie_value)) {
cookie_value[used++] = ','; cookie_value[used++] = '+';
cookie_value[used] = '\0'; cookie_value[used] = '\0';
} else { } else {
break; break;

View File

@@ -177,7 +177,7 @@ int get_user_engines(char ***out_ids, int *out_count) {
} }
char *saveptr; char *saveptr;
char *token = strtok_r(copy, ",", &saveptr); char *token = strtok_r(copy, "+", &saveptr);
while (token) { while (token) {
while (*token == ' ' || *token == '\t') while (*token == ' ' || *token == '\t')
token++; token++;
@@ -191,9 +191,30 @@ int get_user_engines(char ***out_ids, int *out_count) {
} }
} }
token = strtok_r(NULL, ",", &saveptr); token = strtok_r(NULL, "+", &saveptr);
} }
if (count == 0) {
char *copy2 = strdup(cookie);
if (copy2) {
char *saveptr2 = NULL;
char *token2 = strtok_r(copy2, ",", &saveptr2);
while (token2) {
while (*token2 == ' ' || *token2 == '\t')
token2++;
if (token2[0] != '\0' && is_engine_id_enabled(token2)) {
char **new_ids = realloc(ids, sizeof(char *) * (count + 1));
if (new_ids) {
ids = new_ids;
ids[count] = strdup(token2);
count++;
}
}
token2 = strtok_r(NULL, ",", &saveptr2);
}
free(copy2);
}
}
free(copy); free(copy);
free(cookie); free(cookie);