From 869c992acad9f8506e0ce450a9a4b73993eaa1dd Mon Sep 17 00:00:00 2001 From: "me@ow.nekobit.net" Date: Mon, 14 Feb 2022 04:33:52 +0000 Subject: [PATCH] Fix cookies FossilOrigin-Name: b45522c33710cac416f8faa7684a92c5721306d9d2a3d06a0d8f4bdffa1ed260 --- src/base_page.c | 6 +++--- src/local_config.c | 24 ++++++++++++++++++++++++ src/local_config.h | 3 ++- src/page_config.c | 2 ++ static/index.html | 1 - 5 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 src/local_config.c diff --git a/src/base_page.c b/src/base_page.c index 1009958..d34ff5b 100644 --- a/src/base_page.c +++ b/src/base_page.c @@ -16,6 +16,7 @@ * along with this program. If not, see . */ +#include #include #include #include "base_page.h" @@ -33,7 +34,7 @@ void render_base_page(struct base_page* page) char* cookie_read = cookie; struct http_cookie_info info = { 0 }; - /*while (1) + while (!g_config.changed) { cookie_read = parse_cookies(cookie_read, &info); @@ -44,13 +45,12 @@ void render_base_page(struct base_page* page) } if (!cookie_read) break; - }*/ + } char* data; int len = easprintf(&data, data_index_html, L10N[locale][L10N_APP_NAME], g_config.theme, - g_config.theme, L10N[locale][L10N_APP_NAME], L10N[locale][L10N_SEARCH_PLACEHOLDER], L10N[locale][L10N_SEARCH_BUTTON], diff --git a/src/local_config.c b/src/local_config.c new file mode 100644 index 0000000..e9bd98a --- /dev/null +++ b/src/local_config.c @@ -0,0 +1,24 @@ +/* + * RatFE - Lightweight frontend for Pleroma + * Copyright (C) 2022 Nekobit + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +#include "local_config.h" + +struct local_config g_config = { + .changed = 0, + .theme = "ratfe20" +}; diff --git a/src/local_config.h b/src/local_config.h index 860eae8..924cc00 100644 --- a/src/local_config.h +++ b/src/local_config.h @@ -21,9 +21,10 @@ struct local_config { + int changed; char* theme; }; -static struct local_config g_config; +extern struct local_config g_config; #endif // LOCAL_CONFIG_H diff --git a/src/page_config.c b/src/page_config.c index 1688464..5f9425f 100644 --- a/src/page_config.c +++ b/src/page_config.c @@ -64,10 +64,12 @@ void content_config(mastodont_t* api, char** data, size_t size) g_config.theme = info.val; printf("Set-Cookie: %s=%s; HttpOnly; SameSite=Strict;", "theme", info.val); + g_config.changed = 1; } if (!p_query_read) break; } + } struct base_page b = { diff --git a/static/index.html b/static/index.html index a6600b8..97379d4 100644 --- a/static/index.html +++ b/static/index.html @@ -8,7 +8,6 @@ - %s