Skip to content
This repository has been archived by the owner on Dec 14, 2018. It is now read-only.

Resolve path traversals in RazorViewEngine #5610

Closed
wants to merge 1 commit into from

Conversation

pranavkm
Copy link
Contributor

@pranavkm pranavkm commented Dec 8, 2016

This change moves the onus of path resolution from individual IFileProvider instances to RazorViewEngine.

Fixes #5574
Fixes aspnet/MvcPrecompilation#33

This change moves the onus of path resolution from individual IFileProvider instances to RazorViewEngine.

Fixes #5574
Fixes aspnet/MvcPrecompilation#33
}

var pathSegments = new List<StringSegment>();
var tokenizer = new StringTokenizer(absolutePath, new[] { '/', '\\' });
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can store the path separators in a static field.

var viewEngine = CreateViewEngine();

// Act
var result = viewEngine.GetAbsolutePath("/Index.cshtml", "../Shared/_Layout.cshtml");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add another case where the .. comes later, e.g. Foo/../Bar/../../Oops.cshtml?

@pranavkm pranavkm closed this Dec 8, 2016
@pranavkm pranavkm deleted the prkrishn/getabsolutepath branch December 8, 2016 19:38
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants