commit 3e21aaf
default
·
2023-07-14 12:59:50 +0000 UTC
parent 43d2e80
Fixed crash on empty static and history objects.
1 files changed,
+17,
-11
M
html.c
M
html.c
+17,
-11
1@@ -1830,12 +1830,14 @@ int html_get_handler(const xs_dict *req, const char *q_path,
2 char *id = xs_list_get(l, 1);
3 int sz;
4
5- status = static_get(&snac, id, body, &sz,
6+ if (id && *id) {
7+ status = static_get(&snac, id, body, &sz,
8 xs_dict_get(req, "if-none-match"), etag);
9
10- if (valid_status(status)) {
11- *b_size = sz;
12- *ctype = xs_mime_by_ext(id);
13+ if (valid_status(status)) {
14+ *b_size = sz;
15+ *ctype = xs_mime_by_ext(id);
16+ }
17 }
18 }
19 else
20@@ -1843,13 +1845,17 @@ int html_get_handler(const xs_dict *req, const char *q_path,
21 xs *l = xs_split(p_path, "/");
22 char *id = xs_list_get(l, 1);
23
24- if (xs_endswith(id, "timeline.html_")) {
25- // Don't let them in.
26- *b_size = 0;
27- status = 404;
28- } else if ((*body = history_get(&snac, id)) != NULL) {
29- *b_size = strlen(*body);
30- status = 200;
31+ if (id && *id) {
32+ if (xs_endswith(id, "timeline.html_")) {
33+ /* Don't let them in */
34+ *b_size = 0;
35+ status = 404;
36+ }
37+ else
38+ if ((*body = history_get(&snac, id)) != NULL) {
39+ *b_size = strlen(*body);
40+ status = 200;
41+ }
42 }
43 }
44 else