commit 935a0a5

default  ·  2025-01-08 18:56:15 +0000 UTC
parent a6dce99
Fixed crash on NULL hashtag href.
1 files changed,  +13, -10
M html.c
M html.c
+13, -10
 1@@ -2205,18 +2205,21 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only,
 2 
 3             if (xs_type(type) == XSTYPE_STRING && strcmp(type, "Hashtag") == 0) {
 4                 const char *o_href = xs_dict_get(tag, "href");
 5-                xs *href = xs_utf8_to_lower(o_href);
 6 
 7-                if (xs_type(href) == XSTYPE_STRING && xs_str_in(content, href) == -1) {
 8-                    /* not in the content: add here */
 9-                    const char *name = xs_dict_get(tag, "name");
10+                if (xs_type(o_href) == XSTYPE_STRING) {
11+                    xs *href = xs_utf8_to_lower(o_href);
12 
13-                    xs_html_add(add_hashtags,
14-                        xs_html_tag("li",
15-                            xs_html_tag("a",
16-                                xs_html_attr("href", href),
17-                                xs_html_text(name),
18-                                xs_html_text(" "))));
19+                    if (xs_type(href) == XSTYPE_STRING && xs_str_in(content, href) == -1) {
20+                        /* not in the content: add here */
21+                        const char *name = xs_dict_get(tag, "name");
22+
23+                        xs_html_add(add_hashtags,
24+                            xs_html_tag("li",
25+                                xs_html_tag("a",
26+                                    xs_html_attr("href", href),
27+                                    xs_html_text(name),
28+                                    xs_html_text(" "))));
29+                    }
30                 }
31             }
32         }