update quick-xml to 0.37

This commit is contained in:
Lennart
2024-10-28 15:36:39 +01:00
parent c013ffa117
commit 925b26ea0f
5 changed files with 12 additions and 9 deletions

4
Cargo.lock generated
View File

@@ -2307,9 +2307,9 @@ dependencies = [
[[package]] [[package]]
name = "quick-xml" name = "quick-xml"
version = "0.36.2" version = "0.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7649a7b4df05aed9ea7ec6f628c67c9953a43869b8bc50929569b2999d443fe" checksum = "ffbfb3ddf5364c9cfcd65549a1e7b801d0e8d1b14c1a1590a6408aa93cfbfa84"
dependencies = [ dependencies = [
"memchr", "memchr",
"serde", "serde",

View File

@@ -49,7 +49,7 @@ url = "2.5"
roxmltree = "0.20" roxmltree = "0.20"
base64 = "0.22" base64 = "0.22"
thiserror = "1.0" thiserror = "1.0"
quick-xml = { version = "0.36", features = [ quick-xml = { version = "0.37", features = [
"serde", "serde",
"serde-types", "serde-types",
"serialize", "serialize",

View File

@@ -21,7 +21,10 @@ pub enum Error {
PropReadOnly, PropReadOnly,
#[error(transparent)] #[error(transparent)]
XmlDecodeError(#[from] quick_xml::DeError), XmlDeserializationError(#[from] quick_xml::DeError),
#[error(transparent)]
XmlSerializationError(#[from] quick_xml::SeError),
#[error("Internal server error")] #[error("Internal server error")]
Other(#[from] anyhow::Error), Other(#[from] anyhow::Error),
@@ -35,7 +38,8 @@ impl actix_web::error::ResponseError for Error {
Self::NotFound => StatusCode::NOT_FOUND, Self::NotFound => StatusCode::NOT_FOUND,
Self::BadRequest(_) => StatusCode::BAD_REQUEST, Self::BadRequest(_) => StatusCode::BAD_REQUEST,
Self::Unauthorized => StatusCode::UNAUTHORIZED, Self::Unauthorized => StatusCode::UNAUTHORIZED,
Self::XmlDecodeError(_) => StatusCode::BAD_REQUEST, Self::XmlDeserializationError(_) => StatusCode::BAD_REQUEST,
Self::XmlSerializationError(_) => StatusCode::BAD_REQUEST,
Error::PropReadOnly => StatusCode::CONFLICT, Error::PropReadOnly => StatusCode::CONFLICT,
} }
} }

View File

@@ -54,7 +54,7 @@ pub async fn route_propfind<R: ResourceService>(
// A request body is optional. If empty we MUST return all props // A request body is optional. If empty we MUST return all props
let propfind: PropfindElement = if !body.is_empty() { let propfind: PropfindElement = if !body.is_empty() {
quick_xml::de::from_str(&body).map_err(Error::XmlDecodeError)? quick_xml::de::from_str(&body).map_err(Error::XmlDeserializationError)?
} else { } else {
PropfindElement { PropfindElement {
prop: PropfindType::Allprop, prop: PropfindType::Allprop,

View File

@@ -8,7 +8,6 @@ use crate::xml::TagName;
use crate::Error; use crate::Error;
use actix_web::http::StatusCode; use actix_web::http::StatusCode;
use actix_web::{web::Path, HttpRequest}; use actix_web::{web::Path, HttpRequest};
use log::debug;
use rustical_store::auth::User; use rustical_store::auth::User;
use serde::{Deserialize, Serialize}; use serde::{Deserialize, Serialize};
use std::str::FromStr; use std::str::FromStr;
@@ -62,12 +61,12 @@ pub async fn route_proppatch<R: ResourceService>(
let resource_service = R::new(&req, path_components.clone()).await?; let resource_service = R::new(&req, path_components.clone()).await?;
let PropertyupdateElement::<<R::Resource as Resource>::Prop> { operations } = let PropertyupdateElement::<<R::Resource as Resource>::Prop> { operations } =
quick_xml::de::from_str(&body).map_err(Error::XmlDecodeError)?; quick_xml::de::from_str(&body).map_err(Error::XmlDeserializationError)?;
// Extract all set property names without verification // Extract all set property names without verification
// Weird workaround because quick_xml doesn't allow untagged enums // Weird workaround because quick_xml doesn't allow untagged enums
let propnames: Vec<String> = quick_xml::de::from_str::<PropertyupdateElement<TagName>>(&body) let propnames: Vec<String> = quick_xml::de::from_str::<PropertyupdateElement<TagName>>(&body)
.map_err(Error::XmlDecodeError)? .map_err(Error::XmlDeserializationError)?
.operations .operations
.into_iter() .into_iter()
.map(|op_el| match op_el { .map(|op_el| match op_el {