New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix a regression in the HTTPServerRequest.rootDir property. #2032

Merged
merged 2 commits into from Feb 26, 2018

Conversation

Projects
None yet
2 participants
@s-ludwig
Member

s-ludwig commented Jan 13, 2018

Got introduced with the addition of vibe-core compatibility.

auto depth = requestPath.bySegment.walkLength;
import std.algorithm.searching : count;
auto depth = requestPath.bySegment.count!(s => s.name.length > 0);
if (!requestPath.endsWithSlash) depth--;
return depth == 0 ? "./" : replicate("../", depth);

This comment has been minimized.

@wilzbach

wilzbach Jan 28, 2018

Contributor

Hmm that looks potentially dangerous. count returns an unsigned number.
Consider:

/+ dub.sdl:
dependency "vibe-d:core" version="~master"
+/
import vibe.core.path;
import std.stdio;
import std.algorithm;

void main()
{
	auto p = InetPath("");
	p.bySegment.writeln;
	p.endsWithSlash.writeln;
	size_t depth = p.bySegment.count;
	if (!p.endsWithSlash) depth--;
	depth.writeln;
}

https://run.dlang.io/is/toQxsC

This comment has been minimized.

@s-ludwig

s-ludwig Feb 26, 2018

Member

Good catch! Fixed and rebased.

s-ludwig added some commits Jan 13, 2018

Fix a regression in the HTTPServerRequest.rootDir property.
Got introduced with the addition of vibe-core compatibility.

@s-ludwig s-ludwig merged commit cc74389 into master Feb 26, 2018

0 of 4 checks passed

continuous-integration/appveyor/branch Waiting for AppVeyor build to complete
Details
continuous-integration/appveyor/pr Waiting for AppVeyor build to complete
Details
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
continuous-integration/travis-ci/push The Travis CI build is in progress
Details

@s-ludwig s-ludwig deleted the fix_rootdir_property branch Feb 26, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment