commit bd2540e
default
·
2023-11-28 19:04:49 +0000 UTC
parent 97b7100
xs_html() doesn't filter the top string, just returns the generated string.
1 files changed,
+29,
-25
M
html.c
M
html.c
+29,
-25
1@@ -1430,8 +1430,8 @@ xs_html *html_entry_controls(snac *snac, const xs_dict *msg, const char *md5)
2 }
3
4
5-xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
6- int level, const char *md5, int hide_children)
7+xs_str *html_entry(snac *user, xs_dict *msg, int local,
8+ int level, char *md5, int hide_children)
9 {
10 char *id = xs_dict_get(msg, "id");
11 char *type = xs_dict_get(msg, "type");
12@@ -1442,15 +1442,15 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
13
14 /* do not show non-public messages in the public timeline */
15 if ((local || !user) && !is_msg_public(msg))
16- return os;
17+ return NULL;
18
19 /* hidden? do nothing more for this conversation */
20 if (user && is_hidden(user, id))
21- return os;
22+ return NULL;
23
24 /* avoid too deep nesting, as it may be a loop */
25 if (level >= 256)
26- return os;
27+ return NULL;
28
29 if (strcmp(type, "Follow") == 0) {
30 xs_html *h = xs_html_tag("div",
31@@ -1462,32 +1462,31 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
32 xs_html_text(L("follows you"))),
33 html_msg_icon(msg)));
34
35- xs *s1 = xs_html_render(h);
36- return xs_str_cat(os, s1);
37+ return xs_html_render(h);
38 }
39 else
40 if (!xs_match(type, "Note|Question|Page|Article")) {
41 /* skip oddities */
42- return os;
43+ return NULL;
44 }
45
46 /* ignore notes with "name", as they are votes to Questions */
47 if (strcmp(type, "Note") == 0 && !xs_is_null(xs_dict_get(msg, "name")))
48- return os;
49+ return NULL;
50
51 /* bring the main actor */
52 if ((actor = xs_dict_get(msg, "attributedTo")) == NULL)
53- return os;
54+ return NULL;
55
56 /* ignore muted morons immediately */
57 if (user && is_muted(user, actor))
58- return os;
59+ return NULL;
60
61 if ((user == NULL || strcmp(actor, user->actor) != 0)
62 && !valid_status(actor_get(actor, NULL)))
63- return os;
64+ return NULL;
65
66- xs *s = xs_str_new("<div>\n");
67+ xs_str *s = xs_str_new("<div>\n");
68
69 {
70 xs *s1 = xs_fmt("<a name=\"%s_entry\"></a>\n", md5);
71@@ -2018,15 +2017,16 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
72 object_get_by_md5(cmd5, &chd);
73
74 if (chd != NULL && xs_is_null(xs_dict_get(chd, "name"))) {
75- xs *s1 = xs_str_new(NULL);
76- s1 = html_entry(user, s1, chd, local, level + 1, cmd5, hide_children);
77-
78- if (left > 3)
79- xs_html_add(ch_older,
80- xs_html_raw(s1));
81- else
82- xs_html_add(ch_container,
83- xs_html_raw(s1));
84+ xs *s1 = html_entry(user, chd, local, level + 1, cmd5, hide_children);
85+
86+ if (s1 != NULL) {
87+ if (left > 3)
88+ xs_html_add(ch_older,
89+ xs_html_raw(s1));
90+ else
91+ xs_html_add(ch_container,
92+ xs_html_raw(s1));
93+ }
94 }
95 else
96 srv_debug(2, xs_fmt("cannot read child %s", cmd5));
97@@ -2041,7 +2041,7 @@ xs_str *html_entry(snac *user, xs_str *os, const xs_dict *msg, int local,
98
99 s = xs_str_cat(s, "</div>\n</div>\n");
100
101- return xs_str_cat(os, s);
102+ return s;
103 }
104
105
106@@ -2116,7 +2116,8 @@ xs_str *html_timeline(snac *user, const xs_list *list, int local,
107 continue;
108 }
109
110- s = html_entry(user, s, msg, local, 0, v, user ? 0 : 1);
111+ xs *s1 = html_entry(user, msg, local, 0, v, user ? 0 : 1);
112+ s = xs_str_cat(s, s1);
113 }
114
115 s = xs_str_cat(s, "</div>\n");
116@@ -2439,7 +2440,10 @@ xs_str *html_notifications(snac *snac)
117 else {
118 xs *md5 = xs_md5_hex(id, strlen(id));
119
120- s = html_entry(snac, s, obj, 0, 0, md5, 1);
121+ xs *s1 = html_entry(snac, obj, 0, 0, md5, 1);
122+
123+ if (s1 != NULL)
124+ s = xs_str_cat(s, s1);
125 }
126
127 s = xs_str_cat(s, "</div>\n");