Fix export endpoint error with Cyrillic filenames

Content-Disposition header cannot contain non-ASCII characters.
Use RFC 5987 encoding (filename*=UTF-8'') for proper Cyrillic
filename support, with ASCII-only fallback in the base filename.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-03-02 02:25:11 +03:00
parent e8aab43a13
commit 3a3c87164d

View File

@@ -492,9 +492,10 @@ export const exportEndpoint = async (req: AuthRequest, res: Response) => {
const encrypted = encryptEndpointData(exportData);
const safeFileName = endpoint.name.replace(/[^a-zA-Z0-9_\-а-яА-ЯёЁ]/g, '_');
const safeFileName = endpoint.name.replace(/[^a-zA-Z0-9_\-]/g, '_');
const encodedFileName = encodeURIComponent(endpoint.name.replace(/[\/\\:*?"<>|]/g, '_')) + '.kabe';
res.setHeader('Content-Type', 'application/octet-stream');
res.setHeader('Content-Disposition', `attachment; filename="${safeFileName}.kabe"`);
res.setHeader('Content-Disposition', `attachment; filename="${safeFileName}.kabe"; filename*=UTF-8''${encodedFileName}`);
res.send(encrypted);
} catch (error) {
console.error('Export endpoint error:', error);