fix CalDAVTester failure: managed-attachments: Simple non-recurring, non-scheduled update attachment: Test 4: rename of attachment via Content-Disposition:filename=

This commit is contained in:
Ralf Becker 2015-09-29 12:27:49 +00:00
parent 5e2ec5b8d2
commit afa106cbf3

View File

@ -1304,6 +1304,19 @@ class groupdav extends HTTP_WebDAV_Server
} }
else else
{ {
// check for rename of attachment via Content-Disposition:filename=
if (isset($this->_SERVER['HTTP_CONTENT_DISPOSITION']) &&
substr($this->_SERVER['HTTP_CONTENT_DISPOSITION'], 0, 10) === 'attachment' &&
preg_match('/filename="?([^";]+)/', $this->_SERVER['HTTP_CONTENT_DISPOSITION'], $matches) &&
($filename = egw_vfs::basename($matches[1])) != egw_vfs::basename($path))
{
$old_path = $path;
if (!egw_vfs::rename($old_path, $path = egw_vfs::concat(egw_vfs::dirname($path), $filename)))
{
self::xml_error(self::mkprop(self::CALDAV, 'valid-managed-id-parameter', ''));
return '403 Forbidden';
}
}
if (!($to = egw_vfs::fopen($path, 'w')) || if (!($to = egw_vfs::fopen($path, 'w')) ||
isset($options['stream']) && ($copied=stream_copy_to_stream($options['stream'], $to)) === false || isset($options['stream']) && ($copied=stream_copy_to_stream($options['stream'], $to)) === false ||
isset($options['content']) && ($copied=fwrite($to, $options['content'])) === false) isset($options['content']) && ($copied=fwrite($to, $options['content'])) === false)