From bda3db6da8dc6dd71255ed5e053460577e002b05 Mon Sep 17 00:00:00 2001 From: Andrew Ruthven Date: Tue, 2 Mar 2021 00:26:49 +1300 Subject: [PATCH] Return a nicer error message if no user is found for Free/Busy via email Previously a stack trace would be returned as the call to dav_name failed, for example: Exception [0] Can't calculate dav_name for unknown username At line 382 of /usr/share/davical/inc/Principal.php ================= Stack Trace =================== /usr/share/davical/htdocs/freebusy.php[49] Principal->dav_name() --- htdocs/freebusy.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/htdocs/freebusy.php b/htdocs/freebusy.php index 0499e02f..304f7851 100644 --- a/htdocs/freebusy.php +++ b/htdocs/freebusy.php @@ -46,6 +46,11 @@ $request = new CalDAVRequest(array("allow_by_email" => 1)); $path_match = '^'.$request->path; if ( preg_match( '{^/(\S+@[a-z0-9][a-z0-9-]*[.][a-z0-9.-]+)/?$}i', $request->path, $matches ) ) { $principal = new Principal('email',$matches[1]); + + if ( !$principal->Exists() ) { + $request->DoResponse( 404, translate('No user found matching') . ' ' . $matches[1] . "\n" ); + } + $path_match = '^'.$principal->dav_name(); }