summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar green2026-03-17 16:09:19 +0100
committerGravatar green2026-03-17 17:27:18 +0100
commitb51c8f186c1e57e2eac74c8ba266685289a882ea (patch)
tree11d60c42602272cd233e2b91a1e49dcf090ad3e5
parentCall ulimit -n to increase file descriptors in examples/snac_netbsd. (diff)
downloadsnac2-b51c8f186c1e57e2eac74c8ba266685289a882ea.tar.gz
snac2-b51c8f186c1e57e2eac74c8ba266685289a882ea.tar.xz
snac2-b51c8f186c1e57e2eac74c8ba266685289a882ea.zip
fix: memory errors in byte's notification filter
-rw-r--r--html.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/html.c b/html.c
index dda387a..0be0cd8 100644
--- a/html.c
+++ b/html.c
@@ -4111,7 +4111,7 @@ void notify_filter(snac *user, const xs_dict *p_vars)
4111 int folreq_on = (v = xs_dict_get(p_vars, "folreqs_on")) ? strcmp(v, "on") == 0 : 0; 4111 int folreq_on = (v = xs_dict_get(p_vars, "folreqs_on")) ? strcmp(v, "on") == 0 : 0;
4112 int blocks_on = (v = xs_dict_get(p_vars, "blocks_on")) ? strcmp(v, "on") == 0 : 0; 4112 int blocks_on = (v = xs_dict_get(p_vars, "blocks_on")) ? strcmp(v, "on") == 0 : 0;
4113 int polls_on = (v = xs_dict_get(p_vars, "polls_on")) ? strcmp(v, "on") == 0 : 0; 4113 int polls_on = (v = xs_dict_get(p_vars, "polls_on")) ? strcmp(v, "on") == 0 : 0;
4114 xs_dict *filter = xs_dict_new(); 4114 xs *filter = xs_dict_new();
4115 filter = xs_dict_set(filter, "likes", xs_stock(likes_on ? XSTYPE_TRUE : XSTYPE_FALSE)); 4115 filter = xs_dict_set(filter, "likes", xs_stock(likes_on ? XSTYPE_TRUE : XSTYPE_FALSE));
4116 filter = xs_dict_set(filter, "reacts", xs_stock(reacts_on ? XSTYPE_TRUE : XSTYPE_FALSE)); 4116 filter = xs_dict_set(filter, "reacts", xs_stock(reacts_on ? XSTYPE_TRUE : XSTYPE_FALSE));
4117 filter = xs_dict_set(filter, "mentions", xs_stock(ments_on ? XSTYPE_TRUE : XSTYPE_FALSE)); 4117 filter = xs_dict_set(filter, "mentions", xs_stock(ments_on ? XSTYPE_TRUE : XSTYPE_FALSE));
@@ -4122,6 +4122,7 @@ void notify_filter(snac *user, const xs_dict *p_vars)
4122 filter = xs_dict_set(filter, "blocks", xs_stock(blocks_on ? XSTYPE_TRUE : XSTYPE_FALSE)); 4122 filter = xs_dict_set(filter, "blocks", xs_stock(blocks_on ? XSTYPE_TRUE : XSTYPE_FALSE));
4123 filter = xs_dict_set(filter, "polls", xs_stock(polls_on ? XSTYPE_TRUE : XSTYPE_FALSE)); 4123 filter = xs_dict_set(filter, "polls", xs_stock(polls_on ? XSTYPE_TRUE : XSTYPE_FALSE));
4124 user->config = xs_dict_set(user->config, "notify_filter", filter); 4124 user->config = xs_dict_set(user->config, "notify_filter", filter);
4125 user->tz = xs_dict_get_def(user->config, "tz", "UTC"); // previous line invalidates user->tz
4125} 4126}
4126 4127
4127xs_str *html_notifications(snac *user, int skip, int show) 4128xs_str *html_notifications(snac *user, int skip, int show)
@@ -4137,7 +4138,9 @@ xs_str *html_notifications(snac *user, int skip, int show)
4137 xs_html *body = html_user_body(user, 0); 4138 xs_html *body = html_user_body(user, 0);
4138 const xs_dict *n_filter = xs_dict_get(user->config, "notify_filter"); 4139 const xs_dict *n_filter = xs_dict_get(user->config, "notify_filter");
4139 if (!n_filter) { 4140 if (!n_filter) {
4140 user->config = xs_dict_set(user->config, "notify_filter", xs_dict_new()); 4141 xs *filter = xs_dict_new();
4142 user->config = xs_dict_set(user->config, "notify_filter", filter);
4143 user->tz = xs_dict_get_def(user->config, "tz", "UTC"); // previous line invalidates user->tz
4141 n_filter = xs_dict_get(user->config, "notify_filter"); 4144 n_filter = xs_dict_get(user->config, "notify_filter");
4142 } 4145 }
4143 xs *n_list = notify_filter_list(user, n_list_unfilt); 4146 xs *n_list = notify_filter_list(user, n_list_unfilt);
@@ -4158,6 +4161,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
4158 body); 4161 body);
4159 4162
4160 xs *filter_notifs_action = xs_fmt("%s/admin/filter-notifications", user->actor); 4163 xs *filter_notifs_action = xs_fmt("%s/admin/filter-notifications", user->actor);
4164 xs *notifs_action = xs_fmt("%s/notifications", user->actor);
4161 xs_html *notifs_form = xs_html_tag("form", 4165 xs_html *notifs_form = xs_html_tag("form",
4162 xs_html_attr("autocomplete", "off"), 4166 xs_html_attr("autocomplete", "off"),
4163 xs_html_attr("method", "post"), 4167 xs_html_attr("method", "post"),
@@ -4167,7 +4171,7 @@ xs_str *html_notifications(snac *user, int skip, int show)
4167 xs_html_sctag("input", 4171 xs_html_sctag("input",
4168 xs_html_attr("type", "hidden"), 4172 xs_html_attr("type", "hidden"),
4169 xs_html_attr("name", "hard-redir"), 4173 xs_html_attr("name", "hard-redir"),
4170 xs_html_attr("value", xs_fmt("%s/notifications", user->actor))), 4174 xs_html_attr("value", notifs_action)),
4171 html_checkbox("likes_on", L("Likes"), n_likes_on), 4175 html_checkbox("likes_on", L("Likes"), n_likes_on),
4172 html_checkbox("reacts_on", L("Emoji reacts"), n_reacts_on), 4176 html_checkbox("reacts_on", L("Emoji reacts"), n_reacts_on),
4173 html_checkbox("mentions_on", L("Mentions"), n_ments_on), 4177 html_checkbox("mentions_on", L("Mentions"), n_ments_on),