diff --git a/Cargo.lock b/Cargo.lock index 16c26b1..448fc36 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6,7 +6,7 @@ version = "0.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "1be241f88f3b1e7e9a3fbe3b5a8a0f6915b5a1d7ee0d9a248d3376d01068cc60" dependencies = [ - "actix-rt 1.1.1", + "actix-rt", "actix_derive", "bitflags", "bytes 0.5.6", @@ -48,7 +48,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "177837a10863f15ba8d3ae3ec12fac1099099529ed20083a27fdfe247381d0dc" dependencies = [ "actix-codec", - "actix-rt 1.1.1", + "actix-rt", "actix-service", "actix-utils", "derive_more", @@ -68,7 +68,7 @@ checksum = "452299e87817ae5673910e53c243484ca38be3828db819b6011736fc6982e874" dependencies = [ "actix-codec", "actix-connect", - "actix-rt 1.1.1", + "actix-rt", "actix-service", "actix-threadpool", "actix-utils", @@ -117,16 +117,6 @@ dependencies = [ "syn", ] -[[package]] -name = "actix-macros" -version = "0.2.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dbcb2b608f0accc2f5bcf3dd872194ce13d94ee45b571487035864cf966b04ef" -dependencies = [ - "quote", - "syn", -] - [[package]] name = "actix-multipart" version = "0.3.0" @@ -164,7 +154,7 @@ version = "1.1.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "143fcc2912e0d1de2bcf4e2f720d2a60c28652ab4179685a1ee159e0fb3db227" dependencies = [ - "actix-macros 0.1.3", + "actix-macros", "actix-threadpool", "copyless", "futures-channel", @@ -173,17 +163,6 @@ dependencies = [ "tokio 0.2.25", ] -[[package]] -name = "actix-rt" -version = "2.0.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c88cf46527e27f66efcd5831f60b3d9c2dac795b6d255ed17791752d6c36a8ea" -dependencies = [ - "actix-macros 0.2.0", - "futures-core", - "tokio 1.2.0", -] - [[package]] name = "actix-server" version = "1.0.4" @@ -191,7 +170,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "45407e6e672ca24784baa667c5d32ef109ccdd8d5e0b5ebb9ef8a67f4dfb708e" dependencies = [ "actix-codec", - "actix-rt 1.1.1", + "actix-rt", "actix-service", "actix-utils", "futures-channel", @@ -220,8 +199,8 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "47239ca38799ab74ee6a8a94d1ce857014b2ac36f242f70f3f75a66f691e791c" dependencies = [ - "actix-macros 0.1.3", - "actix-rt 1.1.1", + "actix-macros", + "actix-rt", "actix-server", "actix-service", "log", @@ -262,7 +241,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "2e9022dec56632d1d7979e59af14f0597a28a830a9c1c7fec8b2327eb9f16b5a" dependencies = [ "actix-codec", - "actix-rt 1.1.1", + "actix-rt", "actix-service", "bitflags", "bytes 0.5.6", @@ -283,9 +262,9 @@ checksum = "e641d4a172e7faa0862241a20ff4f1f5ab0ab7c279f00c2d4587b77483477b86" dependencies = [ "actix-codec", "actix-http", - "actix-macros 0.1.3", + "actix-macros", "actix-router", - "actix-rt 1.1.1", + "actix-rt", "actix-server", "actix-service", "actix-testing", @@ -456,7 +435,7 @@ checksum = "b381e490e7b0cfc37ebc54079b0413d8093ef43d14a4e4747083f7fa47a9e691" dependencies = [ "actix-codec", "actix-http", - "actix-rt 1.1.1", + "actix-rt", "actix-service", "base64 0.13.0", "bytes 0.5.6", @@ -714,7 +693,7 @@ version = "0.1.0" dependencies = [ "actix", "actix-multipart", - "actix-rt 2.0.2", + "actix-rt", "actix-web", "actix-web-actors", "bcrypt", @@ -2851,11 +2830,7 @@ dependencies = [ "memchr", "mio 0.7.8", "num_cpus", - "once_cell", - "parking_lot", "pin-project-lite 0.2.4", - "signal-hook-registry", - "winapi 0.3.9", ] [[package]] diff --git a/Cargo.toml b/Cargo.toml index 3b21245..89f3816 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,7 +11,7 @@ yaml-rust = "0.4.5" mysql = "20.1.0" actix = "0.10.0" actix-web = "3.3.2" -actix-rt = "2.0.2" +actix-rt = "1.1.1" actix-multipart = "0.3.0" actix-web-actors = "3.0.0" serde = { version = "1.0.123", features = ["derive"] } diff --git a/src/data/base_request_handler.rs b/src/data/base_request_handler.rs index 70d7eb9..01b2e41 100644 --- a/src/data/base_request_handler.rs +++ b/src/data/base_request_handler.rs @@ -36,7 +36,7 @@ struct SuccessMessage { pub struct PostFile { pub name: String, - pub buff: bytes::Bytes, + pub buff: actix_web::web::Bytes, } /// Single request body value diff --git a/src/data/error.rs b/src/data/error.rs index dee74c8..dd084a2 100644 --- a/src/data/error.rs +++ b/src/data/error.rs @@ -1,8 +1,7 @@ use core::fmt; use std::error; use std::error::Error; - -use serde::export::Formatter; +use std::fmt::Formatter; /// Simple rust error /// @@ -37,4 +36,5 @@ impl fmt::Display for ExecError { } } + impl error::Error for ExecError {} \ No newline at end of file diff --git a/src/server.rs b/src/server.rs index e78424e..d7730ae 100644 --- a/src/server.rs +++ b/src/server.rs @@ -4,8 +4,7 @@ use std::pin::Pin; use actix_web::{App, FromRequest, http, HttpMessage, HttpRequest, HttpResponse, HttpServer, web}; use actix_web::dev::{Decompress, Payload, PayloadStream}; use actix_web::error::{ErrorBadRequest, ErrorInternalServerError, PayloadError}; -use actix_web::web::{Bytes, BytesMut}; -use bytes::{Buf, BufMut}; +use actix_web::web::{Bytes, BytesMut, BufMut, Buf}; use encoding_rs::UTF_8; use futures::{FutureExt, Stream, StreamExt}; use futures::future::LocalBoxFuture; diff --git a/src/utils/crypt_utils.rs b/src/utils/crypt_utils.rs index 070a6fa..439a30c 100644 --- a/src/utils/crypt_utils.rs +++ b/src/utils/crypt_utils.rs @@ -59,6 +59,7 @@ pub fn legacy_crypt_pass(pass: &str) -> ResultBoxError { pub fn rand_str(len: usize) -> String { thread_rng() .sample_iter(&Alphanumeric) + .map(char::from) .take(len) .collect() } \ No newline at end of file diff --git a/src/utils/pdf_utils.rs b/src/utils/pdf_utils.rs index 0d980dd..1cf0794 100644 --- a/src/utils/pdf_utils.rs +++ b/src/utils/pdf_utils.rs @@ -7,10 +7,12 @@ use pdf::backend::Backend; use crate::data::error::{ExecError, ResultBoxError}; /// Check out whether a PDF is a valid PDF or not, by trying to open it -pub fn is_valid_pdf(file: &bytes::Bytes) -> ResultBoxError { +pub fn is_valid_pdf(file: &actix_web::web::Bytes) -> ResultBoxError { let backend = file.to_vec(); - match backend.read_xref_table_and_trailer() { + let start_offset = backend.locate_start_offset()?; + + match backend.read_xref_table_and_trailer(start_offset) { Ok((refs, _)) => { if refs.is_empty() { Err(ExecError::boxed_string(format!("Detected a PDF with 0 references (file size: {})!", file.len()))) @@ -20,7 +22,7 @@ pub fn is_valid_pdf(file: &bytes::Bytes) -> ResultBoxError { } Err(e) => { - println!("Error while parsing PDF: {}", e); + println!("Error while parsing PDF: {:?}", e); Ok(false) } }