mirror of
https://gitlab.com/comunic/comunicapiv3
synced 2025-06-20 08:25:16 +00:00
Update dependencies
This commit is contained in:
@ -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