Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions apps/dav/lib/CardDAV/ImageExportPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
use Symfony\Component\HttpFoundation\HeaderUtils;
use Symfony\Component\String\UnicodeString;

class ImageExportPlugin extends ServerPlugin {

Expand Down Expand Up @@ -89,9 +90,7 @@ public function httpGet(RequestInterface $request, ResponseInterface $response)
$response->setHeader('Content-Type', $file->getMimeType());
$fileName = $node->getName() . '.' . PhotoCache::ALLOWED_CONTENT_TYPES[$file->getMimeType()];
$sanitized = str_replace(['/', '\\'], '-', $fileName);
$fallback = @iconv('UTF-8', 'ASCII//TRANSLIT', $sanitized) ?: $sanitized;
$fallback = preg_replace('/[^\x20-\x7e]/', '', $fallback);
$fallback = str_replace('%', '', $fallback);
$fallback = str_replace('%', '', (new UnicodeString($sanitized))->ascii()->toString());
$response->setHeader('Content-Disposition', HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, $sanitized, $fallback));
$response->setStatus(Http::STATUS_OK);

Expand Down
5 changes: 2 additions & 3 deletions apps/dav/lib/Provisioning/Apple/AppleProvisioningPlugin.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Sabre\HTTP\RequestInterface;
use Sabre\HTTP\ResponseInterface;
use Symfony\Component\HttpFoundation\HeaderUtils;
use Symfony\Component\String\UnicodeString;

class AppleProvisioningPlugin extends ServerPlugin {
/**
Expand Down Expand Up @@ -126,9 +127,7 @@ public function httpGet(RequestInterface $request, ResponseInterface $response):

$response->setStatus(Http::STATUS_OK);
$sanitized = str_replace(['/', '\\'], '-', $filename);
$fallback = @iconv('UTF-8', 'ASCII//TRANSLIT', $sanitized) ?: $sanitized;
$fallback = preg_replace('/[^\x20-\x7e]/', '', $fallback);
$fallback = str_replace('%', '', $fallback);
$fallback = str_replace('%', '', (new UnicodeString($sanitized))->ascii()->toString());
$response->setHeader('Content-Disposition', HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, $sanitized, $fallback));
$response->setHeader('Content-Type', 'application/xml; charset=utf-8');
$response->setBody($body);
Expand Down
5 changes: 2 additions & 3 deletions lib/public/AppFramework/Http/DownloadResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

use OCP\AppFramework\Http;
use Symfony\Component\HttpFoundation\HeaderUtils;
use Symfony\Component\String\UnicodeString;

/**
* Prompts the user to download the a file
Expand All @@ -31,9 +32,7 @@ public function __construct(string $filename, string $contentType, int $status =
parent::__construct($status, $headers);

$sanitized = str_replace(['/', '\\'], '-', $filename);
$fallback = @iconv('UTF-8', 'ASCII//TRANSLIT', $sanitized) ?: $sanitized;
$fallback = preg_replace('/[^\x20-\x7e]/', '', $fallback);
$fallback = str_replace('%', '', $fallback);
$fallback = str_replace('%', '', (new UnicodeString($sanitized))->ascii()->toString());
$this->addHeader('Content-Disposition', HeaderUtils::makeDisposition(HeaderUtils::DISPOSITION_ATTACHMENT, $sanitized, $fallback));
$this->addHeader('Content-Type', $contentType);
}
Expand Down
Loading