diff options
| author | 2025-01-12 14:59:28 +0100 | |
|---|---|---|
| committer | 2025-01-12 14:59:28 +0100 | |
| commit | 5aaa6192ef08de7ab6c63e85708a1c825e9ff5f1 (patch) | |
| tree | 768411ed56c9df88dbcfa113e54c4e596fb06db6 | |
| parent | Show event start / end times. (diff) | |
| download | penes-snac2-5aaa6192ef08de7ab6c63e85708a1c825e9ff5f1.tar.gz penes-snac2-5aaa6192ef08de7ab6c63e85708a1c825e9ff5f1.tar.xz penes-snac2-5aaa6192ef08de7ab6c63e85708a1c825e9ff5f1.zip | |
Better dangling hashtag checking.
Diffstat (limited to '')
| -rw-r--r-- | html.c | 14 | ||||
| -rw-r--r-- | xs.h | 3 | ||||
| -rw-r--r-- | xs_version.h | 2 |
3 files changed, 11 insertions, 8 deletions
| @@ -2317,8 +2317,9 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2317 | 2317 | ||
| 2318 | /* show all hashtags that has not been shown previously in the content */ | 2318 | /* show all hashtags that has not been shown previously in the content */ |
| 2319 | const xs_list *tags = xs_dict_get(msg, "tag"); | 2319 | const xs_list *tags = xs_dict_get(msg, "tag"); |
| 2320 | if (xs_type(tags) == XSTYPE_LIST && xs_list_len(tags)) { | 2320 | const char *o_content = xs_dict_get_def(msg, "content", ""); |
| 2321 | const char *o_content = xs_dict_get_def(msg, "content", ""); | 2321 | |
| 2322 | if (xs_is_string(o_content) && xs_is_list(tags) && xs_list_len(tags)) { | ||
| 2322 | xs *content = xs_utf8_to_lower(o_content); | 2323 | xs *content = xs_utf8_to_lower(o_content); |
| 2323 | const xs_dict *tag; | 2324 | const xs_dict *tag; |
| 2324 | 2325 | ||
| @@ -2328,16 +2329,15 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2328 | xs_list_foreach(tags, tag) { | 2329 | xs_list_foreach(tags, tag) { |
| 2329 | const char *type = xs_dict_get(tag, "type"); | 2330 | const char *type = xs_dict_get(tag, "type"); |
| 2330 | 2331 | ||
| 2331 | if (xs_type(type) == XSTYPE_STRING && strcmp(type, "Hashtag") == 0) { | 2332 | if (xs_is_string(type) && strcmp(type, "Hashtag") == 0) { |
| 2332 | const char *o_href = xs_dict_get(tag, "href"); | 2333 | const char *o_href = xs_dict_get(tag, "href"); |
| 2334 | const char *name = xs_dict_get(tag, "name"); | ||
| 2333 | 2335 | ||
| 2334 | if (xs_type(o_href) == XSTYPE_STRING) { | 2336 | if (xs_is_string(o_href) && xs_is_string(name)) { |
| 2335 | xs *href = xs_utf8_to_lower(o_href); | 2337 | xs *href = xs_utf8_to_lower(o_href); |
| 2336 | 2338 | ||
| 2337 | if (xs_str_in(content, href) == -1) { | 2339 | if (xs_str_in(content, href) == -1 && xs_str_in(content, name) == -1) { |
| 2338 | /* not in the content: add here */ | 2340 | /* not in the content: add here */ |
| 2339 | const char *name = xs_dict_get(tag, "name"); | ||
| 2340 | |||
| 2341 | xs_html_add(add_hashtags, | 2341 | xs_html_add(add_hashtags, |
| 2342 | xs_html_tag("li", | 2342 | xs_html_tag("li", |
| 2343 | xs_html_tag("a", | 2343 | xs_html_tag("a", |
| @@ -157,6 +157,9 @@ unsigned int xs_hash_func(const char *data, int size); | |||
| 157 | #define xs_is_true(v) (xs_type((v)) == XSTYPE_TRUE) | 157 | #define xs_is_true(v) (xs_type((v)) == XSTYPE_TRUE) |
| 158 | #define xs_is_false(v) (xs_type((v)) == XSTYPE_FALSE) | 158 | #define xs_is_false(v) (xs_type((v)) == XSTYPE_FALSE) |
| 159 | #define xs_not(v) xs_stock(xs_is_true((v)) ? XSTYPE_FALSE : XSTYPE_TRUE) | 159 | #define xs_not(v) xs_stock(xs_is_true((v)) ? XSTYPE_FALSE : XSTYPE_TRUE) |
| 160 | #define xs_is_string(v) (xs_type((v)) == XSTYPE_STRING) | ||
| 161 | #define xs_is_list(v) (xs_type((v)) == XSTYPE_LIST) | ||
| 162 | #define xs_is_dict(v) (xs_type((v)) == XSTYPE_DICT) | ||
| 160 | 163 | ||
| 161 | #define xs_list_foreach(l, v) for (int ct_##__LINE__ = 0; xs_list_next(l, &v, &ct_##__LINE__); ) | 164 | #define xs_list_foreach(l, v) for (int ct_##__LINE__ = 0; xs_list_next(l, &v, &ct_##__LINE__); ) |
| 162 | #define xs_dict_foreach(l, k, v) for (int ct_##__LINE__ = 0; xs_dict_next(l, &k, &v, &ct_##__LINE__); ) | 165 | #define xs_dict_foreach(l, k, v) for (int ct_##__LINE__ = 0; xs_dict_next(l, &k, &v, &ct_##__LINE__); ) |
diff --git a/xs_version.h b/xs_version.h index ded4335..ce3d06b 100644 --- a/xs_version.h +++ b/xs_version.h | |||
| @@ -1 +1 @@ | |||
| /* c317231894f28c39ba45a46f493f124d12a12f3a 2025-01-12T06:56:21+01:00 */ | /* cebb5663f26bc91b80c787525f5953b97839e0f7 2025-01-12T14:57:12+01:00 */ | ||