Skip to content

Commit

Permalink
Fix assertion when requesting URL containing ':' from serveStaticFiles.
Browse files Browse the repository at this point in the history
Paths containing a colon were considered to be Windows absolute
paths, causing Path.opBinary!("~") to assert. Now, the request is
just ignored (causing a 404 to be gennerated).
  • Loading branch information
dnadlinger committed Jun 19, 2014
1 parent 2a57cdf commit 1151de3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions source/vibe/http/fileserver.d
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,15 @@ HTTPServerRequestDelegate serveStaticFiles(Path local_path, HTTPFileServerSettin
auto rel_path = srv_path[settings.serverPathPrefix.length .. $];
auto rpath = Path(rel_path);
logTrace("Processing '%s'", srv_path);

rpath.normalize();
logDebug("Path '%s' -> '%s'", rel_path, rpath.toNativeString());
if (rpath.empty) {
// TODO: support searching for an index file
return;
} else if (rpath.absolute) {
logDebug("Path is absolute, not responding");
return;
} else if (rpath[0] == "..") return; // don't respond to relative paths outside of the root path

sendFile(req, res, local_path ~ rpath, settings);
Expand Down

0 comments on commit 1151de3

Please sign in to comment.