From f6c13cf313e96ae10f033e57d6afec4d850e63ca Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 30 Dec 2021 18:37:59 +0000 Subject: [PATCH 1/2] Updated actix-web dependency to `4.0.0-beta.18` --- Cargo.lock | 235 ++++++--------------------------- Cargo.toml | 4 +- crates/api/Cargo.toml | 2 +- crates/api_common/Cargo.toml | 2 +- crates/api_crud/Cargo.toml | 2 +- crates/apub/Cargo.toml | 2 +- crates/apub/src/http/routes.rs | 19 +-- crates/apub_lib/Cargo.toml | 2 +- crates/routes/Cargo.toml | 2 +- crates/utils/Cargo.toml | 2 +- crates/websocket/Cargo.toml | 2 +- crates/websocket/src/routes.rs | 2 +- 12 files changed, 58 insertions(+), 218 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 07ad6d2e8..57e1dd74d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -70,9 +70,9 @@ dependencies = [ [[package]] name = "actix-http" -version = "3.0.0-beta.15" +version = "3.0.0-beta.17" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a1ff7b149cc1b99967c22cb81c2c31f128ac88ed12bbf80c29c55a7511d46edb" +checksum = "dac76407e2be239b5e544c9d83bdac4a0d68ae188031ac0424aa3e4868a669be" dependencies = [ "actix-codec", "actix-rt", @@ -87,21 +87,19 @@ dependencies = [ "derive_more", "encoding_rs", "futures-core", - "futures-util", "h2", "http", "httparse", "httpdate", - "itoa", + "itoa 1.0.1", "language-tags", "local-channel", "log", "mime", "percent-encoding", - "pin-project", "pin-project-lite", "rand 0.8.4", - "sha-1 0.9.8", + "sha-1 0.10.0", "smallvec", ] @@ -117,9 +115,9 @@ dependencies = [ [[package]] name = "actix-router" -version = "0.5.0-beta.2" +version = "0.5.0-beta.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "36b95ce0d76d1aa2f98b681702807475ade0f99bd4552546a6843a966d42ea3d" +checksum = "ddd9f117b910fbcce6e9f45092ffd4ff017785a346d09e2d4fd049f4e20384f4" dependencies = [ "bytestring", "firestorm", @@ -142,9 +140,9 @@ dependencies = [ [[package]] name = "actix-server" -version = "2.0.0-rc.1" +version = "2.0.0-rc.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78c9b22794b8af1c2e02434873ef858f2a7db40dbbf861ce77a04cd81ac6b767" +checksum = "29b7894a5b47aa84e15fbe8d89ee953568296a3739c5f6e6b5858802a561390c" dependencies = [ "actix-rt", "actix-service", @@ -171,9 +169,9 @@ dependencies = [ [[package]] name = "actix-tls" -version = "3.0.0-rc.2" +version = "3.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bcebfd4a6255a2a75b7b87c1a3a723c57f08293ca9a7fade692e94515585f7a6" +checksum = "b5ef5760747cdfb108a1f35e6911a7a40939da893f95e035f9eee0c18b4b4025" dependencies = [ "actix-codec", "actix-rt", @@ -200,9 +198,9 @@ dependencies = [ [[package]] name = "actix-web" -version = "4.0.0-beta.14" +version = "4.0.0-beta.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9387ea044357f12b606b8fad0652d3804ba498954f66ae5c677236cb0bd47db4" +checksum = "a542a92e385844d988b34f1af289dbb0ca927c23740076a56fdf770b1af69fbc" dependencies = [ "actix-codec", "actix-http", @@ -219,16 +217,14 @@ dependencies = [ "cfg-if", "cookie", "derive_more", - "either", "encoding_rs", "futures-core", "futures-util", - "itoa", + "itoa 1.0.1", "language-tags", "log", "mime", "once_cell", - "paste", "pin-project-lite", "regex", "serde", @@ -433,12 +429,6 @@ dependencies = [ "uuid", ] -[[package]] -name = "base-x" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4521f3e3d031370679b3b140beb36dfe4801b09ac77e30c61941f97df3ef28b" - [[package]] name = "base64" version = "0.12.3" @@ -507,15 +497,6 @@ dependencies = [ "generic-array 0.12.4", ] -[[package]] -name = "block-buffer" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4152116fd6e9dadb291ae18fc1ec3575ed6d84c29642d97890f4b4a3417297e4" -dependencies = [ - "generic-array 0.14.4", -] - [[package]] name = "block-buffer" version = "0.10.0" @@ -688,12 +669,6 @@ dependencies = [ "xdg", ] -[[package]] -name = "const_fn" -version = "0.4.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f92cfa0fd5690b3cf8c1ef2cabbd9b7ef22fa53cf5e1f92b05103f6d5d1cf6e7" - [[package]] name = "convert_case" version = "0.4.0" @@ -702,12 +677,12 @@ checksum = "6245d59a3e82a7fc217c5828a6692dbc6dfb63a0c8c90495621f7b9d79704a0e" [[package]] name = "cookie" -version = "0.15.1" +version = "0.16.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d5f1c7727e460397e56abc4bddc1d49e07a1ad78fc98eb2e1c8f032a58a2f80d" +checksum = "94d4706de1b0fa5b132270cddffa8585166037822e260a944fe161acd137ca05" dependencies = [ "percent-encoding", - "time 0.2.27", + "time 0.3.5", "version_check", ] @@ -918,7 +893,7 @@ dependencies = [ "convert_case", "proc-macro2 1.0.33", "quote 1.0.10", - "rustc_version 0.4.0", + "rustc_version", "syn 1.0.82", ] @@ -988,15 +963,6 @@ dependencies = [ "generic-array 0.12.4", ] -[[package]] -name = "digest" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d3dd60d1080a57a05ab032377049e0591415d2b31afd7028356dbf3cc6dcb066" -dependencies = [ - "generic-array 0.14.4", -] - [[package]] name = "digest" version = "0.10.0" @@ -1037,12 +1003,6 @@ dependencies = [ "winapi", ] -[[package]] -name = "discard" -version = "1.0.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "212d0f5754cb6769937f4501cc0e67f4f4483c8d2c3e1e922ee9edbe4ab4c7c0" - [[package]] name = "dissimilar" version = "1.0.3" @@ -1432,7 +1392,7 @@ checksum = "1323096b05d41827dadeaee54c9981958c0f94e670bc94ed80037d1a7b8b186b" dependencies = [ "bytes", "fnv", - "itoa", + "itoa 0.4.8", ] [[package]] @@ -1522,7 +1482,7 @@ dependencies = [ "http-body", "httparse", "httpdate", - "itoa", + "itoa 0.4.8", "pin-project-lite", "socket2", "tokio", @@ -1620,6 +1580,12 @@ version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b71991ff56294aa922b450139ee08b3bfc70982c6b2c7562771375cf73542dd4" +[[package]] +name = "itoa" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1aab8fc367588b89dcee83ab0fd66b72b50b72fa1904d7095045ace2b0c81c35" + [[package]] name = "jni" version = "0.19.0" @@ -2697,12 +2663,6 @@ version = "0.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "925383efa346730478fb4838dbe9137d2a47675ad789c546d150a6e1dd4ab31c" -[[package]] -name = "proc-macro-hack" -version = "0.5.19" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbf0c48bc1d91375ae5c3cd81e3722dff1abcf81a30960240640d223f59fe0e5" - [[package]] name = "proc-macro2" version = "0.4.30" @@ -3045,22 +3005,13 @@ dependencies = [ "quick-xml", ] -[[package]] -name = "rustc_version" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "138e3e0acb6c9fb258b19b67cb8abd63c00679d2851805ea151465464fe9030a" -dependencies = [ - "semver 0.9.0", -] - [[package]] name = "rustc_version" version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bfa0f585226d2e68097d4f95d113b15b83a82e819ab25717ec0590d9584ef366" dependencies = [ - "semver 1.0.4", + "semver", ] [[package]] @@ -3171,27 +3122,12 @@ dependencies = [ "markup5ever_rcdom", ] -[[package]] -name = "semver" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1d7eb9ef2c18661902cc47e535f9bc51b78acd254da71d375c2f6720d9a40403" -dependencies = [ - "semver-parser", -] - [[package]] name = "semver" version = "1.0.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "568a8e6258aa33c13358f81fd834adb854c6f7c9468520910a9b1e8fac068012" -[[package]] -name = "semver-parser" -version = "0.7.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "388a1df253eca08550bef6c72392cfe7c30914bf41df5269b68cbd6ff8f570a3" - [[package]] name = "serde" version = "1.0.131" @@ -3219,7 +3155,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d0ffa0837f2dfa6fb90868c2b5468cad482e175f7dad97e7421951e663f2b527" dependencies = [ "indexmap", - "itoa", + "itoa 0.4.8", "ryu", "serde", ] @@ -3231,7 +3167,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "edfa57a7f8d9c1d260a549e7224100f6c43d43f9103e06dd8b4095a9b2b43ce9" dependencies = [ "form_urlencoded", - "itoa", + "itoa 0.4.8", "ryu", "serde", ] @@ -3295,23 +3231,15 @@ dependencies = [ [[package]] name = "sha-1" -version = "0.9.8" +version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" +checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f" dependencies = [ - "block-buffer 0.9.0", "cfg-if", "cpufeatures", - "digest 0.9.0", - "opaque-debug 0.3.0", + "digest 0.10.0", ] -[[package]] -name = "sha1" -version = "0.6.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2579985fda508104f7587689507983eadd6a6e84dd35d6d115361f530916fa0d" - [[package]] name = "sha2" version = "0.10.0" @@ -3403,70 +3331,12 @@ version = "0.5.2" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6e63cff320ae2c57904679ba7cb63280a3dc4613885beafb148ee7bf9aa9042d" -[[package]] -name = "standback" -version = "0.2.17" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e113fb6f3de07a243d434a56ec6f186dfd51cb08448239fe7bcae73f87ff28ff" -dependencies = [ - "version_check", -] - [[package]] name = "static_assertions" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" -[[package]] -name = "stdweb" -version = "0.4.20" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d022496b16281348b52d0e30ae99e01a73d737b2f45d38fed4edf79f9325a1d5" -dependencies = [ - "discard", - "rustc_version 0.2.3", - "stdweb-derive", - "stdweb-internal-macros", - "stdweb-internal-runtime", - "wasm-bindgen", -] - -[[package]] -name = "stdweb-derive" -version = "0.5.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c87a60a40fccc84bef0652345bbbbbe20a605bf5d0ce81719fc476f5c03b50ef" -dependencies = [ - "proc-macro2 1.0.33", - "quote 1.0.10", - "serde", - "serde_derive", - "syn 1.0.82", -] - -[[package]] -name = "stdweb-internal-macros" -version = "0.2.9" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58fa5ff6ad0d98d1ffa8cb115892b6e69d67799f6763e162a1c9db421dc22e11" -dependencies = [ - "base-x", - "proc-macro2 1.0.33", - "quote 1.0.10", - "serde", - "serde_derive", - "serde_json", - "sha1", - "syn 1.0.82", -] - -[[package]] -name = "stdweb-internal-runtime" -version = "0.1.5" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213701ba3370744dcd1a12960caa4843b3d68b4d1c0a5d575e0d65b2ee9d16c0" - [[package]] name = "string_cache" version = "0.8.2" @@ -3640,53 +3510,22 @@ dependencies = [ "winapi", ] -[[package]] -name = "time" -version = "0.2.27" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4752a97f8eebd6854ff91f1c1824cd6160626ac4bd44287f7f4ea2035a02a242" -dependencies = [ - "const_fn", - "libc", - "standback", - "stdweb", - "time-macros", - "version_check", - "winapi", -] - [[package]] name = "time" version = "0.3.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "41effe7cfa8af36f439fac33861b66b049edc6f9a32331e2312660529c1c24ad" dependencies = [ - "itoa", + "itoa 0.4.8", "libc", + "time-macros", ] [[package]] name = "time-macros" -version = "0.1.1" +version = "0.2.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "957e9c6e26f12cb6d0dd7fc776bb67a706312e7299aed74c8dd5b17ebb27e2f1" -dependencies = [ - "proc-macro-hack", - "time-macros-impl", -] - -[[package]] -name = "time-macros-impl" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd3c141a1b43194f3f56a1411225df8646c55781d5f26db825b3d98507eb482f" -dependencies = [ - "proc-macro-hack", - "proc-macro2 1.0.33", - "quote 1.0.10", - "standback", - "syn 1.0.82", -] +checksum = "25eb0ca3468fc0acc11828786797f6ef9aa1555e4a211a60d64cc8e4d1be47d6" [[package]] name = "tinyvec" @@ -3797,9 +3636,9 @@ dependencies = [ [[package]] name = "tracing-actix-web" -version = "0.5.0-beta.5" +version = "0.5.0-beta.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "13030b85c40d37169eee20eec527f7e87724e6128efa2ae791d6ffdd4046d32f" +checksum = "da8e6a7393e9b680de78d876f8c1432aebf56f3e70346a4a821160c04677a272" dependencies = [ "actix-web", "pin-project", diff --git a/Cargo.toml b/Cargo.toml index 817fb7f6e..18bbf1255 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -48,9 +48,9 @@ diesel_migrations = "1.4.0" chrono = { version = "0.4.19", features = ["serde"] } serde = { version = "1.0.131", features = ["derive"] } actix = "0.12.0" -actix-web = { version = "4.0.0-beta.14", default-features = false, features = ["rustls"] } +actix-web = { version = "4.0.0-beta.18", default-features = false, features = ["rustls"] } tracing = "0.1.29" -tracing-actix-web = { version = "0.5.0-beta.5", default-features = false } +tracing-actix-web = { version = "0.5.0-beta.8", default-features = false } tracing-error = "0.2.0" tracing-log = "0.1.2" tracing-subscriber = { version = "0.3.3", features = ["env-filter"] } diff --git a/crates/api/Cargo.toml b/crates/api/Cargo.toml index d7258e5cf..07daf268c 100644 --- a/crates/api/Cargo.toml +++ b/crates/api/Cargo.toml @@ -28,7 +28,7 @@ chrono = { version = "0.4.19", features = ["serde"] } serde_json = { version = "1.0.72", features = ["preserve_order"] } serde = { version = "1.0.131", features = ["derive"] } actix = "0.12.0" -actix-web = { version = "4.0.0-beta.14", default-features = false } +actix-web = { version = "4.0.0-beta.18", default-features = false } actix-rt = { version = "2.5.0", default-features = false } rand = "0.8.4" strum = "0.23.0" diff --git a/crates/api_common/Cargo.toml b/crates/api_common/Cargo.toml index 602d10cb7..0a804a4ee 100644 --- a/crates/api_common/Cargo.toml +++ b/crates/api_common/Cargo.toml @@ -20,7 +20,7 @@ lemmy_db_schema = { version = "=0.15.0-rc.6", path = "../db_schema" } lemmy_utils = { version = "=0.15.0-rc.6", path = "../utils" } serde = { version = "1.0.131", features = ["derive"] } diesel = "1.4.8" -actix-web = { version = "4.0.0-beta.14", default-features = false, features = ["cookies"] } +actix-web = { version = "4.0.0-beta.18", default-features = false, features = ["cookies"] } chrono = { version = "0.4.19", features = ["serde"] } serde_json = { version = "1.0.72", features = ["preserve_order"] } tracing = "0.1.29" diff --git a/crates/api_crud/Cargo.toml b/crates/api_crud/Cargo.toml index 659385cd8..c2b97678d 100644 --- a/crates/api_crud/Cargo.toml +++ b/crates/api_crud/Cargo.toml @@ -23,7 +23,7 @@ chrono = { version = "0.4.19", features = ["serde"] } serde_json = { version = "1.0.72", features = ["preserve_order"] } serde = { version = "1.0.131", features = ["derive"] } actix = "0.12.0" -actix-web = { version = "4.0.0-beta.14", default-features = false } +actix-web = { version = "4.0.0-beta.18", default-features = false } actix-rt = { version = "2.5.0", default-features = false } tracing = "0.1.29" rand = "0.8.4" diff --git a/crates/apub/Cargo.toml b/crates/apub/Cargo.toml index d02a41344..881ca0d41 100644 --- a/crates/apub/Cargo.toml +++ b/crates/apub/Cargo.toml @@ -28,7 +28,7 @@ serde_json = { version = "1.0.72", features = ["preserve_order"] } serde = { version = "1.0.131", features = ["derive"] } serde_with = "1.11.0" actix = "0.12.0" -actix-web = { version = "4.0.0-beta.14", default-features = false } +actix-web = { version = "4.0.0-beta.18", default-features = false } actix-rt = { version = "2.5.0", default-features = false } tracing = "0.1.29" rand = "0.8.4" diff --git a/crates/apub/src/http/routes.rs b/crates/apub/src/http/routes.rs index ea54cd482..4837d0b24 100644 --- a/crates/apub/src/http/routes.rs +++ b/crates/apub/src/http/routes.rs @@ -1,18 +1,19 @@ use crate::http::{ comment::get_apub_comment, community::{ - community_inbox, - get_apub_community_followers, - get_apub_community_http, - get_apub_community_moderators, - get_apub_community_outbox, + community_inbox, get_apub_community_followers, get_apub_community_http, + get_apub_community_moderators, get_apub_community_outbox, }, get_activity, person::{get_apub_person_http, get_apub_person_outbox, person_inbox}, post::get_apub_post, shared_inbox, }; -use actix_web::{dev::RequestHead, guard::Guard, http::Method, *}; +use actix_web::{ + guard::{Guard, GuardContext}, + http::Method, + web, +}; use http_signature_normalization_actix::digest::middleware::VerifyDigest; use lemmy_utils::settings::structs::Settings; use sha2::{Digest, Sha256}; @@ -64,11 +65,11 @@ pub fn config(cfg: &mut web::ServiceConfig, settings: &Settings) { struct InboxRequestGuard; impl Guard for InboxRequestGuard { - fn check(&self, request: &RequestHead) -> bool { - if request.method != Method::POST { + fn check(&self, request: &GuardContext) -> bool { + if request.head().method != Method::POST { return false; } - if let Some(val) = request.headers.get("Content-Type") { + if let Some(val) = request.head().headers.get("Content-Type") { return val .to_str() .expect("Content-Type header contains non-ascii chars.") diff --git a/crates/apub_lib/Cargo.toml b/crates/apub_lib/Cargo.toml index a46d3c356..433913d57 100644 --- a/crates/apub_lib/Cargo.toml +++ b/crates/apub_lib/Cargo.toml @@ -24,7 +24,7 @@ openssl = "0.10.38" once_cell = "1.8.0" http = "0.2.5" sha2 = "0.10.0" -actix-web = { version = "4.0.0-beta.14", default-features = false } +actix-web = { version = "4.0.0-beta.18", default-features = false } http-signature-normalization-actix = { version = "0.5.0-beta.14", default-features = false, features = ["server", "sha-2"] } http-signature-normalization-reqwest = { version = "0.4.0", default-features = false, features = ["sha-2", "middleware"] } background-jobs = "0.11.0" diff --git a/crates/routes/Cargo.toml b/crates/routes/Cargo.toml index a832c17a4..ff0b3d1c0 100644 --- a/crates/routes/Cargo.toml +++ b/crates/routes/Cargo.toml @@ -20,7 +20,7 @@ lemmy_api_common = { version = "=0.15.0-rc.6", path = "../api_common" } lemmy_apub = { version = "=0.15.0-rc.6", path = "../apub" } diesel = "1.4.8" actix = "0.12.0" -actix-web = { version = "4.0.0-beta.14", default-features = false, features = ["rustls"] } +actix-web = { version = "4.0.0-beta.18", default-features = false, features = ["rustls"] } actix-web-actors = { version = "4.0.0-beta.8", default-features = false } actix-http = "3.0.0-beta.15" sha2 = "0.10.0" diff --git a/crates/utils/Cargo.toml b/crates/utils/Cargo.toml index 20fcef5b3..a8c35a06f 100644 --- a/crates/utils/Cargo.toml +++ b/crates/utils/Cargo.toml @@ -28,7 +28,7 @@ comrak = { version = "0.12.1", default-features = false } once_cell = "1.8.0" openssl = "0.10.38" url = { version = "2.2.2", features = ["serde"] } -actix-web = { version = "4.0.0-beta.14", default-features = false, features = ["rustls"] } +actix-web = { version = "4.0.0-beta.18", default-features = false, features = ["rustls"] } actix-rt = { version = "2.5.0", default-features = false } anyhow = "1.0.51" reqwest = { version = "0.11.7", features = ["json"] } diff --git a/crates/websocket/Cargo.toml b/crates/websocket/Cargo.toml index f11671783..c59eb458c 100644 --- a/crates/websocket/Cargo.toml +++ b/crates/websocket/Cargo.toml @@ -32,5 +32,5 @@ tokio = "1.14.0" strum = "0.23.0" strum_macros = "0.23.1" chrono = { version = "0.4.19", features = ["serde"] } -actix-web = { version = "4.0.0-beta.14", default-features = false, features = ["rustls"] } +actix-web = { version = "4.0.0-beta.18", default-features = false, features = ["rustls"] } actix-web-actors = { version = "4.0.0-beta.8", default-features = false } diff --git a/crates/websocket/src/routes.rs b/crates/websocket/src/routes.rs index 71df55155..41b178246 100644 --- a/crates/websocket/src/routes.rs +++ b/crates/websocket/src/routes.rs @@ -4,7 +4,7 @@ use crate::{ LemmyContext, }; use actix::prelude::*; -use actix_web::*; +use actix_web::{web, Error, HttpRequest, HttpResponse}; use actix_web_actors::ws; use lemmy_utils::{utils::get_ip, ConnectionId, IpAddr}; use std::time::{Duration, Instant}; From 1943bcd7f5be20b880c52aa7565f48295c1dce32 Mon Sep 17 00:00:00 2001 From: Rob Ede Date: Thu, 30 Dec 2021 18:39:28 +0000 Subject: [PATCH 2/2] Prevent panic on InboxRequestGuard --- crates/apub/src/http/routes.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/apub/src/http/routes.rs b/crates/apub/src/http/routes.rs index 4837d0b24..a57290e4b 100644 --- a/crates/apub/src/http/routes.rs +++ b/crates/apub/src/http/routes.rs @@ -1,8 +1,11 @@ use crate::http::{ comment::get_apub_comment, community::{ - community_inbox, get_apub_community_followers, get_apub_community_http, - get_apub_community_moderators, get_apub_community_outbox, + community_inbox, + get_apub_community_followers, + get_apub_community_http, + get_apub_community_moderators, + get_apub_community_outbox, }, get_activity, person::{get_apub_person_http, get_apub_person_outbox, person_inbox}, @@ -11,7 +14,7 @@ use crate::http::{ }; use actix_web::{ guard::{Guard, GuardContext}, - http::Method, + http::{header, Method}, web, }; use http_signature_normalization_actix::digest::middleware::VerifyDigest; @@ -65,15 +68,12 @@ pub fn config(cfg: &mut web::ServiceConfig, settings: &Settings) { struct InboxRequestGuard; impl Guard for InboxRequestGuard { - fn check(&self, request: &GuardContext) -> bool { - if request.head().method != Method::POST { + fn check(&self, ctx: &GuardContext) -> bool { + if ctx.head().method != Method::POST { return false; } - if let Some(val) = request.head().headers.get("Content-Type") { - return val - .to_str() - .expect("Content-Type header contains non-ascii chars.") - .starts_with("application/"); + if let Some(val) = ctx.head().headers.get(header::CONTENT_TYPE) { + return val.as_bytes().starts_with(b"application/"); } false }