diff options
| -rw-r--r-- | html.c | 8 | ||||
| -rw-r--r-- | xs.h | 5 | ||||
| -rw-r--r-- | xs_version.h | 2 |
3 files changed, 7 insertions, 8 deletions
| @@ -2275,18 +2275,18 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2275 | if (strcmp(type, "Event") == 0) { /** Event start and end times **/ | 2275 | if (strcmp(type, "Event") == 0) { /** Event start and end times **/ |
| 2276 | const char *s_time = xs_dict_get(msg, "startTime"); | 2276 | const char *s_time = xs_dict_get(msg, "startTime"); |
| 2277 | 2277 | ||
| 2278 | if (xs_type(s_time) == XSTYPE_STRING) { | 2278 | if (xs_is_string(s_time) && strlen(s_time) > 20) { |
| 2279 | const char *e_time = xs_dict_get(msg, "endTime"); | 2279 | const char *e_time = xs_dict_get(msg, "endTime"); |
| 2280 | const char *tz = xs_dict_get(msg, "timezone"); | 2280 | const char *tz = xs_dict_get(msg, "timezone"); |
| 2281 | 2281 | ||
| 2282 | xs *s = xs_replace_i(xs_dup(s_time), "T", " "); | 2282 | xs *s = xs_replace_i(xs_dup(s_time), "T", " "); |
| 2283 | xs *e = NULL; | 2283 | xs *e = NULL; |
| 2284 | 2284 | ||
| 2285 | if (xs_type(e_time) == XSTYPE_STRING) | 2285 | if (xs_is_string(e_time) && strlen(e_time) > 20) |
| 2286 | e = xs_replace_i(xs_dup(e_time), "T", " "); | 2286 | e = xs_replace_i(xs_dup(e_time), "T", " "); |
| 2287 | 2287 | ||
| 2288 | /* if the event has a timezone, crop the offsets */ | 2288 | /* if the event has a timezone, crop the offsets */ |
| 2289 | if (xs_type(tz) == XSTYPE_STRING) { | 2289 | if (xs_is_string(tz)) { |
| 2290 | s = xs_crop_i(s, 0, 19); | 2290 | s = xs_crop_i(s, 0, 19); |
| 2291 | 2291 | ||
| 2292 | if (e) | 2292 | if (e) |
| @@ -2297,7 +2297,7 @@ xs_html *html_entry(snac *user, xs_dict *msg, int read_only, | |||
| 2297 | 2297 | ||
| 2298 | /* if start and end share the same day, crop it from the end */ | 2298 | /* if start and end share the same day, crop it from the end */ |
| 2299 | if (e && memcmp(s, e, 11) == 0) | 2299 | if (e && memcmp(s, e, 11) == 0) |
| 2300 | e = xs_crop_i(e, 11, strlen(e)); | 2300 | e = xs_crop_i(e, 11, 0); |
| 2301 | 2301 | ||
| 2302 | if (e) | 2302 | if (e) |
| 2303 | s = xs_str_cat(s, " / ", e); | 2303 | s = xs_str_cat(s, " / ", e); |
| @@ -626,15 +626,14 @@ int xs_between(const char *prefix, const char *str, const char *suffix) | |||
| 626 | xs_str *xs_crop_i(xs_str *str, int start, int end) | 626 | xs_str *xs_crop_i(xs_str *str, int start, int end) |
| 627 | /* crops the string to be only from start to end */ | 627 | /* crops the string to be only from start to end */ |
| 628 | { | 628 | { |
| 629 | XS_ASSERT_TYPE(str, XSTYPE_STRING); | ||
| 630 | |||
| 631 | int sz = strlen(str); | 629 | int sz = strlen(str); |
| 632 | 630 | ||
| 633 | if (end <= 0) | 631 | if (end <= 0) |
| 634 | end = sz + end; | 632 | end = sz + end; |
| 635 | 633 | ||
| 636 | /* crop from the top */ | 634 | /* crop from the top */ |
| 637 | str[end] = '\0'; | 635 | if (end > 0 && end < sz) |
| 636 | str[end] = '\0'; | ||
| 638 | 637 | ||
| 639 | /* crop from the bottom */ | 638 | /* crop from the bottom */ |
| 640 | str = xs_collapse(str, 0, start); | 639 | str = xs_collapse(str, 0, start); |
diff --git a/xs_version.h b/xs_version.h index ce3d06b..12f713a 100644 --- a/xs_version.h +++ b/xs_version.h | |||
| @@ -1 +1 @@ | |||
| /* cebb5663f26bc91b80c787525f5953b97839e0f7 2025-01-12T14:57:12+01:00 */ | /* b865e89769aedfdbc61251e94451e9d37579f52e 2025-01-12T16:17:47+01:00 */ | ||