mirror of
https://github.com/actix/actix-web.git
synced 2025-04-12 12:54:06 +00:00
fix: Permit serving .well-known directories
This commit is contained in:
parent
002c1b5a19
commit
7d79e347e8
1 changed files with 32 additions and 1 deletions
|
@ -44,7 +44,7 @@ impl PathBufWrap {
|
|||
if segment == ".." {
|
||||
segment_count -= 1;
|
||||
buf.pop();
|
||||
} else if !hidden_files && segment.starts_with('.') {
|
||||
} else if segment != ".well-known" && !hidden_files && segment.starts_with('.') {
|
||||
return Err(UriSegmentError::BadStart('.'));
|
||||
} else if segment.starts_with('*') {
|
||||
return Err(UriSegmentError::BadStart('*'));
|
||||
|
@ -105,6 +105,10 @@ mod tests {
|
|||
PathBufWrap::from_str("/test/.tt").map(|t| t.0),
|
||||
Err(UriSegmentError::BadStart('.'))
|
||||
);
|
||||
assert_eq!(
|
||||
PathBufWrap::from_str("/.well-known/test/.tt").map(|t| t.0),
|
||||
Err(UriSegmentError::BadStart('.'))
|
||||
);
|
||||
assert_eq!(
|
||||
PathBufWrap::from_str("/test/*tt").map(|t| t.0),
|
||||
Err(UriSegmentError::BadStart('*'))
|
||||
|
@ -144,6 +148,33 @@ mod tests {
|
|||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_parse_well_known() {
|
||||
assert_eq!(
|
||||
PathBufWrap::parse_path("/.well-known/test/.tt", false).map(|t| t.0),
|
||||
Err(UriSegmentError::BadStart('.'))
|
||||
);
|
||||
assert_eq!(
|
||||
PathBufWrap::parse_path("/.well-known/test/foo", false)
|
||||
.unwrap()
|
||||
.0,
|
||||
PathBuf::from_iter(vec![".well-known", "test", "foo"])
|
||||
);
|
||||
|
||||
assert_eq!(
|
||||
PathBufWrap::parse_path("/.well-known/test/.tt", true)
|
||||
.unwrap()
|
||||
.0,
|
||||
PathBuf::from_iter(vec![".well-known", "test", ".tt"])
|
||||
);
|
||||
assert_eq!(
|
||||
PathBufWrap::parse_path("/.well-known/test/foo", true)
|
||||
.unwrap()
|
||||
.0,
|
||||
PathBuf::from_iter(vec![".well-known", "test", "foo"])
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn path_traversal() {
|
||||
assert_eq!(
|
||||
|
|
Loading…
Reference in a new issue