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()
This commit is contained in:
Andrew Ruthven 2021-03-02 00:26:49 +13:00
parent 90bcfba683
commit bda3db6da8

View File

@ -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();
}