diff --git a/inc/CalDAVRequest.php b/inc/CalDAVRequest.php index f395671c..3c22a228 100644 --- a/inc/CalDAVRequest.php +++ b/inc/CalDAVRequest.php @@ -317,8 +317,6 @@ class CalDAVRequest if ( ! isset($this->timeout) || $this->timeout == 0 ) $this->timeout = (isset($c->default_lock_timeout) ? $c->default_lock_timeout : 900); } - $this->principal = new Principal('path',$this->path); - /** * RFC2518, 5.2: URL pointing to a collection SHOULD end in '/', and if it does not then * we SHOULD return a Content-location header with the correction... @@ -431,7 +429,14 @@ EOSQL; /** * Extract the user whom we are accessing */ - $this->principal = new DAVPrincipal( array( "path" => $this->path, "options" => $this->options ) ); + + if ( $this->options['allow_by_email'] && preg_match( '{^/(\S+@[a-z0-9][a-z0-9-]*[.][a-z0-9.-]+)/?$}i', $this->path, $matches ) ) { + $this->principal = new DAVPrincipal( array( "email" => $matches[1], "options" => $this->options ) ); +// @dbg_error_log('caldav', 'DAVPrincipal by email: %s', print_r($this->principal, true) ); + } else { + $this->principal = new DAVPrincipal( array( "path" => $this->path, "options" => $this->options ) ); +// @dbg_error_log('caldav', 'Principal by path: %s', $this->path ); + } $this->user_no = $this->principal->user_no(); $this->username = $this->principal->username(); $this->by_email = $this->principal->byEmail();