public abstract class PathUtils extends Object
Modifier and Type | Method and Description |
---|---|
static boolean |
checkResource(org.springframework.core.io.Resource resource,
org.springframework.core.io.Resource location,
List<org.springframework.core.io.Resource> allowedLocations)
Perform additional checks on a resolved resource beyond checking whether the
resources exists and is readable.
|
static boolean |
isInvalidEncodedLocation(String location)
Check whether the given location contains invalid escape sequences.
|
static boolean |
isInvalidEncodedPath(String path)
Check whether the given path contains invalid escape sequences.
|
static boolean |
isInvalidPath(String path)
Identifies invalid resource paths.
|
protected static String |
processPath(String path)
Process the given resource path.
|
public static boolean isInvalidEncodedLocation(String location)
location
- the location to validatetrue
if the path is invalid, false
otherwisepublic static boolean isInvalidEncodedPath(String path)
path
- the path to validatetrue
if the path is invalid, false
otherwiseprotected static String processPath(String path)
The default implementation replaces:
" / // foo/bar"
becomes "/foo/bar"
.
path
- path to processpublic static boolean isInvalidPath(String path)
StringUtils.cleanPath(java.lang.String)
.
valid URL
or would represent one after the leading slash is removed.
Note: this method assumes that leading, duplicate '/' or control characters (e.g. white space) have been trimmed so that the path starts predictably with a single '/' or does not have one.
path
- the path to validatetrue
if the path is invalid, false
otherwisepublic static boolean checkResource(org.springframework.core.io.Resource resource, org.springframework.core.io.Resource location, List<org.springframework.core.io.Resource> allowedLocations) throws IOException
allowed locations
.resource
- the resource to checklocation
- the location relative to which the resource was foundallowedLocations
- set of allowed locationsIOException
- if Resource URLS fail to parse.Copyright © 2020 Pivotal Software, Inc.. All rights reserved.