summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2022-11-16 13:13:31 +0100
committerGravatar default2022-11-16 13:13:31 +0100
commit236ca9af6b66cfc0c20c4fd5a2b5c8c187bfe3f4 (patch)
treec808cdec072ca3dc8af8ac65df44ff35bc5f52b2
parentUpdated TODO. (diff)
downloadsnac2-236ca9af6b66cfc0c20c4fd5a2b5c8c187bfe3f4.tar.gz
snac2-236ca9af6b66cfc0c20c4fd5a2b5c8c187bfe3f4.tar.xz
snac2-236ca9af6b66cfc0c20c4fd5a2b5c8c187bfe3f4.zip
Call sanitize() as soon as possible.
-rw-r--r--format.c6
-rw-r--r--html.c6
-rw-r--r--snac.h4
3 files changed, 7 insertions, 9 deletions
diff --git a/format.c b/format.c
index 0e5c95b..80e62d1 100644
--- a/format.c
+++ b/format.c
@@ -87,7 +87,7 @@ static d_char *format_line(const char *line)
87} 87}
88 88
89 89
90d_char *not_really_markdown(char *content) 90d_char *not_really_markdown(const char *content)
91/* formats a content using some Markdown rules */ 91/* formats a content using some Markdown rules */
92{ 92{
93 d_char *s = xs_str_new(NULL); 93 d_char *s = xs_str_new(NULL);
@@ -164,11 +164,11 @@ d_char *not_really_markdown(char *content)
164 164
165 165
166const char *valid_tags[] = { 166const char *valid_tags[] = {
167 "a", "p", "br", "br/", "img", "blockquote", "ul", "li", 167 "a", "p", "br", "br/", "blockquote", "ul", "li",
168 "span", "i", "b", "pre", "code", "em", "strong", NULL 168 "span", "i", "b", "pre", "code", "em", "strong", NULL
169}; 169};
170 170
171d_char *sanitize(d_char *content) 171d_char *sanitize(const char *content)
172/* cleans dangerous HTML output */ 172/* cleans dangerous HTML output */
173{ 173{
174 d_char *s = xs_str_new(NULL); 174 d_char *s = xs_str_new(NULL);
diff --git a/html.c b/html.c
index 863de75..7d59592 100644
--- a/html.c
+++ b/html.c
@@ -627,7 +627,7 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i
627 } 627 }
628 628
629 { 629 {
630 xs *c = xs_dup(xs_dict_get(msg, "content")); 630 xs *c = sanitize(xs_dict_get(msg, "content"));
631 char *p, *v; 631 char *p, *v;
632 632
633 /* do some tweaks to the content */ 633 /* do some tweaks to the content */
@@ -663,9 +663,7 @@ d_char *html_entry(snac *snac, d_char *os, char *msg, xs_set *seen, int local, i
663 } 663 }
664 } 664 }
665 665
666 xs *sc = sanitize(c); 666 s = xs_str_cat(s, c);
667
668 s = xs_str_cat(s, sc);
669 } 667 }
670 668
671 s = xs_str_cat(s, "\n"); 669 s = xs_str_cat(s, "\n");
diff --git a/snac.h b/snac.h
index 140cc6e..4e4a981 100644
--- a/snac.h
+++ b/snac.h
@@ -135,8 +135,8 @@ int activitypub_post_handler(d_char *req, char *q_path,
135 char *payload, int p_size, 135 char *payload, int p_size,
136 char **body, int *b_size, char **ctype); 136 char **body, int *b_size, char **ctype);
137 137
138d_char *not_really_markdown(char *content); 138d_char *not_really_markdown(const char *content);
139d_char *sanitize(d_char *str); 139d_char *sanitize(const char *str);
140 140
141int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char **ctype); 141int html_get_handler(d_char *req, char *q_path, char **body, int *b_size, char **ctype);
142int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size, 142int html_post_handler(d_char *req, char *q_path, d_char *payload, int p_size,