Some checks failed
CI / PHP 8.3 / mariadb:10.6 (pull_request) Successful in 1m14s
CI / PHP 8.4 / mariadb:10.6 (pull_request) Successful in 1m12s
CI / PHP 8.4 / mariadb:11.4 (pull_request) Successful in 1m7s
CI / PHP 8.3 / mariadb:11.4 (pull_request) Successful in 1m19s
CI / PHP 8.3 / mysql:8.0 (pull_request) Successful in 1m32s
CI / PHP 8.4 / mysql:8.0 (pull_request) Successful in 1m22s
CI / PHP 8.4 / mysql:8.4 (pull_request) Successful in 1m32s
CI / PHP 8.3 / mysql:8.4 (pull_request) Successful in 1m35s
CI / Build-Artefakte aktuell (pull_request) Failing after 1m7s
- Laravel 13 mit Filament 5 (Admin), Inertia 3 + Vue 3 + Vuetify 4 (Material 3) - Anmeldung über Fortify (Login, Passwort vergessen/ändern), keine Selbstregistrierung - Profil mit Profilbild (WebP in festen Größen), Personenseiten, Header mit Avatar-Menü - Material-3-Farbschema aus der Primärfarbe, hell/dunkel/System pro Person - Basis-Branding (Portalname, Logo, Primärfarbe) im Admin unter „Erscheinungsbild“ - Benutzerverwaltung im Admin, Zugang vorläufig über is_admin - vendor/ (ohne Dev-Pakete) und Frontend-Build mitversioniert, Dev-Pakete in vendor-dev/ - PHPUnit-Tests gegen MySQL/MariaDB, Forgejo-CI-Matrix, Docker-Entwicklungsumgebung - VERSION, CHANGELOG.md und CONTRIBUTING.md mit Release-Ablauf Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
64 lines
1.9 KiB
PHP
64 lines
1.9 KiB
PHP
<?php
|
|
|
|
/**
|
|
* League.Csv (https://csv.thephpleague.com)
|
|
*
|
|
* (c) Ignace Nyamagana Butera <nyamsprod@gmail.com>
|
|
*
|
|
* For the full copyright and license information, please view the LICENSE
|
|
* file that was distributed with this source code.
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace League\Csv;
|
|
|
|
use InvalidArgumentException;
|
|
|
|
use function filter_var;
|
|
use function header;
|
|
use function rawurlencode;
|
|
use function str_contains;
|
|
use function str_replace;
|
|
|
|
use const FILTER_FLAG_STRIP_HIGH;
|
|
use const FILTER_FLAG_STRIP_LOW;
|
|
|
|
/**
|
|
* Send the CSV headers.
|
|
*
|
|
* Adapted from Symfony\Component\HttpFoundation\ResponseHeaderBag::makeDisposition
|
|
*
|
|
* @see https://tools.ietf.org/html/rfc6266#section-4.3
|
|
*
|
|
* @internal
|
|
*/
|
|
final class HttpHeaders
|
|
{
|
|
/**
|
|
* @throws InvalidArgumentException
|
|
*/
|
|
public static function forFileDownload(string $filename, string $contentType): void
|
|
{
|
|
if (str_contains($filename, '/') || str_contains($filename, '\\')) {
|
|
throw new InvalidArgumentException('The filename `'.$filename.'` cannot contain the "/" or "\" characters.');
|
|
}
|
|
|
|
/** @var string $filteredName */
|
|
$filteredName = filter_var($filename, FILTER_UNSAFE_RAW, FILTER_FLAG_STRIP_LOW | FILTER_FLAG_STRIP_HIGH);
|
|
$fallbackName = str_replace('%', '', $filteredName);
|
|
$disposition = 'attachment;filename="'.str_replace('"', '\\"', $fallbackName).'"';
|
|
if ($filename !== $fallbackName) {
|
|
$disposition .= ";filename*=UTF-8''".preg_replace_callback(
|
|
'/[%"\x00-\x1F\x7F-\xFF]/',
|
|
static fn (array $matches): string => strtolower(rawurlencode($matches[0])),
|
|
$filename
|
|
);
|
|
}
|
|
|
|
header('content-type: '.$contentType);
|
|
header('content-transfer-encoding: binary');
|
|
header('content-description: File Transfer');
|
|
header('content-disposition: '.$disposition);
|
|
}
|
|
}
|