pub struct PathBufWrap(/* private fields */);Expand description
Secure Path Traversal Guard
This struct parses a request-uri PathBuf
Implementations§
Source§impl PathBufWrap
impl PathBufWrap
Sourcepub fn parse_unprocessed_req(
req: &HttpRequest,
hidden_files: bool,
) -> Result<Self, UriSegmentError>
pub fn parse_unprocessed_req( req: &HttpRequest, hidden_files: bool, ) -> Result<Self, UriSegmentError>
Parse a safe path from the unprocessed tail of a supplied
HttpRequest, given the choice of allowing hidden files to be
considered valid segments.
This uses HttpRequest::match_info and
Path::unprocessed, which returns the part of the
path not matched by route patterns. This is useful for mounted services (eg. Files),
where only the tail should be parsed.
Path traversal is guarded by this method.
Sourcepub fn parse_req_path(
req: &HttpRequest,
hidden_files: bool,
) -> Result<Self, UriSegmentError>
pub fn parse_req_path( req: &HttpRequest, hidden_files: bool, ) -> Result<Self, UriSegmentError>
Parse a safe path from the full request path of a supplied
HttpRequest, given the choice of allowing hidden files to be
considered valid segments.
This uses HttpRequest::path, and is more appropriate
for non-mounted handlers that want the entire request path.
Path traversal is guarded by this method.
Sourcepub fn parse_path(
path: &str,
hidden_files: bool,
) -> Result<Self, UriSegmentError>
pub fn parse_path( path: &str, hidden_files: bool, ) -> Result<Self, UriSegmentError>
Parse a path, giving the choice of allowing hidden files to be considered valid segments.
Path traversal is guarded by this method.
Trait Implementations§
Source§impl AsRef<Path> for PathBufWrap
impl AsRef<Path> for PathBufWrap
Source§impl Debug for PathBufWrap
impl Debug for PathBufWrap
Source§impl FromRequest for PathBufWrap
impl FromRequest for PathBufWrap
Source§type Error = UriSegmentError
type Error = UriSegmentError
Source§type Future = Ready<Result<PathBufWrap, <PathBufWrap as FromRequest>::Error>>
type Future = Ready<Result<PathBufWrap, <PathBufWrap as FromRequest>::Error>>
Self. Read moreSource§fn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future
fn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future
Self from request parts asynchronously.