Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,10 @@ abstract class FileAndResourceDirectives extends ExecutionDirectives {
* Completes GET requests with the content of the given resource loaded from the default ClassLoader,
* using the default content type resolver.
* If the resource cannot be found or read the Route rejects the request.
*
* The path is passed to the class loader as given: unlike `getFromResourceDirectory` this directive does not
* reject `..` or separator characters, so a path built from request input can resolve to a resource outside the
* intended prefix. Validate any request-derived part of the path, or use `getFromResourceDirectory` instead.
*/
def getFromResource(path: String): Route = RouteAdapter {
D.getFromResource(path)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ trait FileAndResourceDirectives {
* Completes GET requests with the content of the given class-path resource.
* If the resource cannot be found or read the Route rejects the request.
*
* The resource name is passed to the class loader as given: unlike `getFromResourceDirectory` this directive does
* not reject `..` or separator characters, so a name built from request input can resolve to a resource outside the
* intended prefix. Validate any request-derived part of the name, or use `getFromResourceDirectory` instead.
*
* @group fileandresource
*/
def getFromResource(resourceName: String)(implicit resolver: ContentTypeResolver): Route =
Expand All @@ -103,6 +107,8 @@ trait FileAndResourceDirectives {
* Completes GET requests with the content of the given resource.
* If the resource is a directory or cannot be found or read the Route rejects the request.
*
* The resource name is not checked for path traversal, see `getFromResource(resourceName)` above.
*
* @group fileandresource
*/
def getFromResource(
Expand Down