aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-04-30 19:07:37 +0000
committerOmar Polo <op@omarpolo.com>2021-04-30 19:07:37 +0000
commit737a6b50c599460a5e69c8a89e41f9881ff07f88 (patch)
tree7d6bb9326bb8934b7b6dbbcd2ceccc8fc8830b42
parentfdea6aa0bca24f6f947e2126ce101fd59caa7a31 (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--ChangeLog2
-rwxr-xr-xregress/runtime2
-rw-r--r--server.c2
3 files changed, 5 insertions, 1 deletions
diff --git a/ChangeLog b/ChangeLog
index f6c4288..580f507 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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"
diff --git a/server.c b/server.c
index 60d1da8..79c7d9c 100644
--- a/server.c
+++ b/server.c
@@ -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':