aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php')
-rw-r--r--vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php28
1 files changed, 24 insertions, 4 deletions
diff --git a/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php b/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
index de8b3bb84..d015589ad 100644
--- a/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
+++ b/vendor/sabre/dav/lib/CardDAV/VCFExportPlugin.php
@@ -70,14 +70,34 @@ class VCFExportPlugin extends DAV\ServerPlugin {
$aclPlugin->checkPrivileges($path, '{DAV:}read');
}
- $response->setHeader('Content-Type', 'text/directory');
- $response->setStatus(200);
-
$nodes = $this->server->getPropertiesForPath($path, [
'{' . Plugin::NS_CARDDAV . '}address-data',
], 1);
- $response->setBody($this->generateVCF($nodes));
+ $format = 'text/directory';
+
+ $output = null;
+ $filenameExtension = null;
+
+ switch ($format) {
+ case 'text/directory':
+ $output = $this->generateVCF($nodes);
+ $filenameExtension = '.vcf';
+ break;
+ }
+
+ $filename = preg_replace(
+ '/[^a-zA-Z0-9-_ ]/um',
+ '',
+ $node->getName()
+ );
+ $filename .= '-' . date('Y-m-d') . $filenameExtension;
+
+ $response->setHeader('Content-Disposition', 'attachment; filename="' . $filename . '"');
+ $response->setHeader('Content-Type', $format);
+
+ $response->setStatus(200);
+ $response->setBody($output);
// Returning false to break the event chain
return false;