Browse Source

[core] preserve PATH_INFO case on case-insensitive fs (fixes #406)

attempt to preserve PATH_INFO case even when the
URI is mapped onto a case-insensitive file system.

NTFS (Windows) is case-insensitive (even though it is case-preserving)
HFS+ (Mac OS X) can be formatted to be case-insensitive

x-ref:
  "... PATH_INFO ... improperly converted to lowercase"
  https://redmine.lighttpd.net/issues/406
personal/stbuehler/mod-csrf-old
Glenn Strauss 6 years ago
parent
commit
4edb65cfa1
  1. 15
      src/response.c

15
src/response.c

@ -696,13 +696,24 @@ handler_t http_response_prepare(server *srv, connection *con) {
/* we have a PATHINFO */
if (pathinfo) {
buffer_copy_string(con->request.pathinfo, pathinfo);
size_t len = strlen(pathinfo), reqlen;
if (con->conf.force_lowercase_filenames
&& len <= (reqlen = buffer_string_length(con->request.uri))
&& 0 == strncasecmp(con->request.uri->ptr + reqlen - len, pathinfo, len)) {
/* attempt to preserve case-insensitive PATH_INFO
* (works in common case where mod_alias, mod_magnet, and other modules
* have not modified the PATH_INFO portion of request URI, or did so
* with exactly the PATH_INFO desired) */
buffer_copy_string_len(con->request.pathinfo, con->request.uri->ptr + reqlen - len, len);
} else {
buffer_copy_string_len(con->request.pathinfo, pathinfo, len);
}
/*
* shorten uri.path
*/
buffer_string_set_length(con->uri.path, buffer_string_length(con->uri.path) - strlen(pathinfo));
buffer_string_set_length(con->uri.path, buffer_string_length(con->uri.path) - len);
}
if (con->conf.log_request_handling) {

Loading…
Cancel
Save