aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel GarcĂ­a <[email protected]>2020-07-21 16:31:31 +0200
committerGitHub <[email protected]>2020-07-21 16:31:31 +0200
commit11845d9f5b40867d39645e80d0eef0ff694b3eee (patch)
treee802535050fa0566bbfb7092718d0b55b9f0b468
parent0b04caab781e7a0879f3bd761a869c486df6d13f (diff)
parentde70fbf88a762836bc7c97da9474870172b45221 (diff)
downloadvaultwarden-1.16.0.tar.gz
vaultwarden-1.16.0.zip
Merge pull request #1061 from jjlin/use-strip-prefix1.16.0
Use `strip_prefix()` instead of `trim_start_matches()` as appropriate
-rw-r--r--src/util.rs9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/util.rs b/src/util.rs
index a8215b54..0a21d346 100644
--- a/src/util.rs
+++ b/src/util.rs
@@ -160,9 +160,7 @@ impl Fairing for BetterLogging {
}
let uri = request.uri();
let uri_path = uri.path();
- // FIXME: trim_start_matches() could result in over-trimming in pathological cases;
- // strip_prefix() would be a better option once it's stable.
- let uri_subpath = uri_path.trim_start_matches(&CONFIG.domain_path());
+ let uri_subpath = uri_path.strip_prefix(&CONFIG.domain_path()).unwrap_or(uri_path);
if self.0 || LOGGED_ROUTES.iter().any(|r| uri_subpath.starts_with(r)) {
match uri.query() {
Some(q) => info!(target: "request", "{} {}?{}", method, uri_path, &q[..q.len().min(30)]),
@@ -175,9 +173,8 @@ impl Fairing for BetterLogging {
if !self.0 && request.method() == Method::Options {
return;
}
- // FIXME: trim_start_matches() could result in over-trimming in pathological cases;
- // strip_prefix() would be a better option once it's stable.
- let uri_subpath = request.uri().path().trim_start_matches(&CONFIG.domain_path());
+ let uri_path = request.uri().path();
+ let uri_subpath = uri_path.strip_prefix(&CONFIG.domain_path()).unwrap_or(uri_path);
if self.0 || LOGGED_ROUTES.iter().any(|r| uri_subpath.starts_with(r)) {
let status = response.status();
if let Some(route) = request.route() {