Compare commits

...

4 Commits

Author SHA1 Message Date
Stefan Bühler a5d3e11c1f [tests] add tests for mod_dirlist 1 year ago
Stefan Bühler 76fccefc84 [core] encode path in li_vrequest_redirect_directory 1 year ago
Stefan Bühler 51a7fd577c [core]: fix query string handling in li_vrequest_redirect_directory (dirlist, index) 1 year ago
Stefan Bühler 92681fcde4 [tests] fix PrepareDir 1 year ago
  1. 3
      src/main/virtualrequest.c
  2. 2
      tests/base.py
  3. 42
      tests/t-dirlist.py

3
src/main/virtualrequest.c

@ -1,5 +1,6 @@
#include <lighttpd/base.h>
#include <lighttpd/encoding.h>
#include <lighttpd/plugin_core.h>
#include <lighttpd/filter_buffer_on_disk.h>
@ -563,7 +564,7 @@ gboolean li_vrequest_redirect_directory(liVRequest *vr) {
} else {
g_string_append_len(uri, GSTR_LEN(vr->coninfo->local_addr_str));
}
g_string_append_len(uri, GSTR_LEN(vr->request.uri.raw_orig_path));
li_string_encode_append(vr->request.uri.path->str, uri, LI_ENCODING_URI);
g_string_append_c(uri, '/');
if (vr->request.uri.query->len) {
g_string_append_c(uri, '?');

2
tests/base.py

@ -226,7 +226,7 @@ var.vhosts = var.vhosts + [ "%s" => {
def PrepareDir(self, dirname):
"""remembers which directories have been prepared and while remove them on cleanup; returns absolute pathname"""
self._test_cleanup_dirs.append(fname)
self._test_cleanup_dirs.append(dirname)
return self.tests.PrepareDir(dirname)
def MissingFeature(self, feature):

42
tests/t-dirlist.py

@ -0,0 +1,42 @@
# -*- coding: utf-8 -*-
from base import *
from requests import *
class TestDirlist(CurlRequest):
URL = "/foo/"
EXPECT_RESPONSE_CODE = 200
EXPECT_RESPONSE_HEADERS = [("Content-Type", "text/html; charset=utf-8")]
class TestRedirectDir(CurlRequest):
URL = "/foo"
EXPECT_RESPONSE_CODE = 301
EXPECT_RESPONSE_HEADERS = [("Location", "http://dirlist/foo/")]
class TestRedirectDirWithQuery(CurlRequest):
URL = "/foo?bar=baz"
EXPECT_RESPONSE_CODE = 301
EXPECT_RESPONSE_HEADERS = [("Location", "http://dirlist/foo/?bar=baz")]
class TestRedirectDirWithQueryAndSpecialChars(CurlRequest):
URL = "/f%3f%20o?bar=baz"
EXPECT_RESPONSE_CODE = 301
EXPECT_RESPONSE_HEADERS = [("Location", "http://dirlist/f%3f%20o/?bar=baz")]
class Test(GroupTest):
group = [
TestDirlist,
TestRedirectDir,
TestRedirectDirWithQuery,
]
config = """
setup { module_load "mod_dirlist"; }
dirlist;
"""
def Prepare(self):
self.PrepareDir("www/vhosts/dirlist/foo")
self.PrepareFile("www/vhosts/dirlist/foo/test.txt", "abc")
self.PrepareDir("www/vhosts/dirlist/f? o")
self.PrepareFile("www/vhosts/dirlist/f? o/test.txt", "abc")
Loading…
Cancel
Save