summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2025-01-08 19:56:15 +0100
committerGravatar default2025-01-08 19:56:15 +0100
commit935a0a5a7d9f50427fe15b0a8b947d51db177cdc (patch)
tree084f91f5aec5c4846e1bc30b0cf9564e75afb2ac
parentDo a lower case search of hashtags in the content. (diff)
downloadsnac2-935a0a5a7d9f50427fe15b0a8b947d51db177cdc.tar.gz
snac2-935a0a5a7d9f50427fe15b0a8b947d51db177cdc.tar.xz
snac2-935a0a5a7d9f50427fe15b0a8b947d51db177cdc.zip
Fixed crash on NULL hashtag href.
-rw-r--r--html.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/html.c b/html.c
index 7c46c76..294faa3 100644
--- a/html.c
+++ b/html.c
@@ -2205,18 +2205,21 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
2205 2205
2206 if (xs_type(type) == XSTYPE_STRING && strcmp(type, "Hashtag") == 0) { 2206 if (xs_type(type) == XSTYPE_STRING && strcmp(type, "Hashtag") == 0) {
2207 const char *o_href = xs_dict_get(tag, "href"); 2207 const char *o_href = xs_dict_get(tag, "href");
2208 xs *href = xs_utf8_to_lower(o_href);
2209 2208
2210 if (xs_type(href) == XSTYPE_STRING && xs_str_in(content, href) == -1) { 2209 if (xs_type(o_href) == XSTYPE_STRING) {
2211 /* not in the content: add here */ 2210 xs *href = xs_utf8_to_lower(o_href);
2212 const char *name = xs_dict_get(tag, "name");
2213 2211
2214 xs_html_add(add_hashtags, 2212 if (xs_type(href) == XSTYPE_STRING && xs_str_in(content, href) == -1) {
2215 xs_html_tag("li", 2213 /* not in the content: add here */
2216 xs_html_tag("a", 2214 const char *name = xs_dict_get(tag, "name");
2217 xs_html_attr("href", href), 2215
2218 xs_html_text(name), 2216 xs_html_add(add_hashtags,
2219 xs_html_text(" ")))); 2217 xs_html_tag("li",
2218 xs_html_tag("a",
2219 xs_html_attr("href", href),
2220 xs_html_text(name),
2221 xs_html_text(" "))));
2222 }
2220 } 2223 }
2221 } 2224 }
2222 } 2225 }