mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 00:15:17 +00:00
Update dependencies
This commit is contained in:
@ -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
|
||||
|
@ -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 {}
|
@ -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;
|
||||
|
@ -59,6 +59,7 @@ pub fn legacy_crypt_pass(pass: &str) -> ResultBoxError<String> {
|
||||
pub fn rand_str(len: usize) -> String {
|
||||
thread_rng()
|
||||
.sample_iter(&Alphanumeric)
|
||||
.map(char::from)
|
||||
.take(len)
|
||||
.collect()
|
||||
}
|
@ -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<bool> {
|
||||
pub fn is_valid_pdf(file: &actix_web::web::Bytes) -> ResultBoxError<bool> {
|
||||
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<bool> {
|
||||
}
|
||||
|
||||
Err(e) => {
|
||||
println!("Error while parsing PDF: {}", e);
|
||||
println!("Error while parsing PDF: {:?}", e);
|
||||
Ok(false)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user