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-10-09 18:04:40 +00:00
parent 7ed6c0b3f1
commit 20ede24957

View File

@ -1304,6 +1304,19 @@ class groupdav extends HTTP_WebDAV_Server
}
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')) ||
isset($options['stream']) && ($copied=stream_copy_to_stream($options['stream'], $to)) === false ||
isset($options['content']) && ($copied=fwrite($to, $options['content'])) === false)