Compare commits

...

5 Commits

Author SHA1 Message Date
AverageHelper 68ddd2bbf6
Merge d623e7b269 into cede0c6dbb 2025-03-10 14:54:20 -07:00
AverageHelper d623e7b269
doc: Also add changelog entry to actix-web 2024-12-08 18:06:18 -07:00
AverageHelper aa764a75f0
chore: Add a doc comment 2024-12-08 17:48:56 -07:00
AverageHelper 59360be522
chore: Add changelog entry 2024-12-08 17:35:43 -07:00
AverageHelper 7d79e347e8
fix: Permit serving .well-known directories 2024-12-08 17:29:06 -07:00
3 changed files with 35 additions and 1 deletions

View File

@ -3,6 +3,7 @@
## Unreleased
- Minimum supported Rust version (MSRV) is now 1.75.
- Allow serving `.well-known` files when serving dotfiles is otherwise disallowed.
## 0.6.6

View File

@ -40,11 +40,12 @@ impl PathBufWrap {
return Err(UriSegmentError::BadChar('/'));
}
// disallow invalid or suspicious path segments
for segment in path.split('/') {
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 +106,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 +149,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!(

View File

@ -21,6 +21,7 @@
- On Windows, an error is now returned from `HttpServer::bind()` (or TLS variants) when binding to a socket that's already in use.
- Update `brotli` dependency to `7`.
- Minimum supported Rust version (MSRV) is now 1.75.
- Allow serving `.well-known` files when serving dotfiles is otherwise disallowed.
## 4.9.0