mirror of
https://github.com/lennart-k/rustical.git
synced 2025-12-14 10:32:19 +00:00
Fix bug with missing trailing slash in propfind response
This commit is contained in:
@@ -76,13 +76,8 @@ pub(crate) async fn route_propfind<R: ResourceService>(
|
||||
let mut member_responses = Vec::new();
|
||||
if depth != &Depth::Zero {
|
||||
for member in resource_service.get_members(path_components).await? {
|
||||
// Collections should have a trailing slash
|
||||
let mut name = member.get_name();
|
||||
if R::IS_COLLECTION {
|
||||
name.push('/')
|
||||
}
|
||||
member_responses.push(member.propfind_typed(
|
||||
&format!("{}/{}", path.trim_end_matches('/'), name),
|
||||
member_responses.push(member.propfind(
|
||||
&format!("{}/{}", path.trim_end_matches('/'), member.get_name()),
|
||||
&propfind_member.prop,
|
||||
puri,
|
||||
principal,
|
||||
@@ -90,7 +85,7 @@ pub(crate) async fn route_propfind<R: ResourceService>(
|
||||
}
|
||||
}
|
||||
|
||||
let response = resource.propfind_typed(path, &propfind_self.prop, puri, principal)?;
|
||||
let response = resource.propfind(path, &propfind_self.prop, puri, principal)?;
|
||||
|
||||
Ok(MultistatusElement {
|
||||
responses: vec![response],
|
||||
|
||||
@@ -37,6 +37,8 @@ pub trait Resource: Clone + Send + 'static {
|
||||
type Error: From<crate::Error>;
|
||||
type Principal: Principal;
|
||||
|
||||
const IS_COLLECTION: bool;
|
||||
|
||||
fn get_resourcetype(&self) -> Resourcetype;
|
||||
|
||||
fn list_props() -> Vec<(Option<Namespace<'static>>, &'static str)> {
|
||||
@@ -95,13 +97,19 @@ pub trait Resource: Clone + Send + 'static {
|
||||
principal: &Self::Principal,
|
||||
) -> Result<UserPrivilegeSet, Self::Error>;
|
||||
|
||||
fn propfind_typed(
|
||||
fn propfind(
|
||||
&self,
|
||||
path: &str,
|
||||
prop: &PropfindType<<Self::Prop as PropName>::Names>,
|
||||
principal_uri: &impl PrincipalUri,
|
||||
principal: &Self::Principal,
|
||||
) -> Result<ResponseElement<Self::Prop>, Self::Error> {
|
||||
// Collections have a trailing slash
|
||||
let mut path = path.to_string();
|
||||
if Self::IS_COLLECTION && !path.ends_with('/') {
|
||||
path.push('/');
|
||||
}
|
||||
|
||||
// TODO: Support include element
|
||||
let (props, invalid_props): (HashSet<<Self::Prop as PropName>::Names>, Vec<_>) = match prop
|
||||
{
|
||||
|
||||
@@ -18,7 +18,6 @@ pub trait ResourceService: Clone + Sized + Send + Sync + AxumMethods + 'static {
|
||||
type PrincipalUri: PrincipalUri;
|
||||
|
||||
const DAV_HEADER: &'static str;
|
||||
const IS_COLLECTION: bool;
|
||||
|
||||
async fn get_members(
|
||||
&self,
|
||||
|
||||
Reference in New Issue
Block a user