diff options
author | Omar Polo <op@omarpolo.com> | 2021-04-30 19:07:37 +0000 |
---|---|---|
committer | Omar Polo <op@omarpolo.com> | 2021-04-30 19:07:37 +0000 |
commit | 737a6b50c599460a5e69c8a89e41f9881ff07f88 (patch) | |
tree | 7d6bb9326bb8934b7b6dbbcd2ceccc8fc8830b42 | |
parent | fdea6aa0bca24f6f947e2126ce101fd59caa7a31 (diff) |
ensure %p (path) is always absolute
with the recent changes, sometimes the path may not start with a '/'.
This ensures that %s is ALWAYS an absolute path.
-rw-r--r-- | ChangeLog | 2 | ||||
-rwxr-xr-x | regress/runtime | 2 | ||||
-rw-r--r-- | server.c | 2 |
3 files changed, 5 insertions, 1 deletions
@@ -1,5 +1,7 @@ 2021-04-30 Omar Polo <op@omarpolo.com> + * server.c (fmt_sbuf): ensure %p (path) is always absolute + * gmid.c (load_vhosts): allow ``root'' rule to be specified per-location block 2021-04-29 Omar Polo <op@omarpolo.com> diff --git a/regress/runtime b/regress/runtime index 53f1549..5e61d2a 100755 --- a/regress/runtime +++ b/regress/runtime @@ -271,7 +271,7 @@ restart eq "$(head /dir/foo.gmi)" "40 % /foo.gmi 10965 localhost test" echo OK GET /dir/foo.gmi with strip and block -eq "$(head /bigfile)" "40 % 10965 localhost test" +eq "$(head /bigfile)" "40 % / 10965 localhost test" echo OK GET /bigfile with strip and block check "should be running" @@ -514,6 +514,8 @@ fmt_sbuf(const char *fmt, struct client *c, const char *path) strlcat(c->sbuf, "%", sizeof(c->sbuf)); break; case 'p': + if (*path != '/') + strlcat(c->sbuf, "/", sizeof(c->sbuf)); strlcat(c->sbuf, path, sizeof(c->sbuf)); break; case 'q': |