[Pkg-owncloud-commits] [php-sabredav] 138/220: Set a filename with a .vcf extension when exporting address books
David Prévot
taffit at moszumanska.debian.org
Thu May 12 01:21:18 UTC 2016
This is an automated email from the git hooks/post-receive script.
taffit pushed a commit to branch master
in repository php-sabredav.
commit 4e2b5c13e77a6e40e575a4962f6787d17577ad75
Author: Robin McCorkell <robin at mccorkell.me.uk>
Date: Sun Apr 10 19:41:04 2016 +0100
Set a filename with a .vcf extension when exporting address books
Filename format is <addressbookname>-YYYY-MM-DD.vcf. Content type used
to be text/directory, but according to RFC 6350 that mimetype is
deprecated and text/vcard should be used instead, so this commit also
changes that.
---
lib/CardDAV/VCFExportPlugin.php | 28 ++++++++++++++++++++++++----
1 file changed, 24 insertions(+), 4 deletions(-)
diff --git a/lib/CardDAV/VCFExportPlugin.php b/lib/CardDAV/VCFExportPlugin.php
index de8b3bb..d015589 100644
--- a/lib/CardDAV/VCFExportPlugin.php
+++ b/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;
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-php/php-sabredav.git
More information about the Pkg-owncloud-commits
mailing list