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:
@@ -492,9 +492,10 @@ export const exportEndpoint = async (req: AuthRequest, res: Response) => {
|
|||||||
|
|
||||||
const encrypted = encryptEndpointData(exportData);
|
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-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);
|
res.send(encrypted);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Export endpoint error:', error);
|
console.error('Export endpoint error:', error);
|
||||||
|
|||||||
Reference in New Issue
Block a user