mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-08-27 04:07:05 +00:00
🌐 fix: Percent-encode X-File-Metadata header for Unicode filenames (#12983)
* 🌐 fix: Percent-encode X-File-Metadata header for Unicode filenames After #12977 preserved Unicode in filenames, the download route crashes with ERR_INVALID_CHAR because JSON.stringify(file) now contains non-ASCII characters that Node.js rejects in HTTP headers per RFC 7230. Wrap the header value in encodeURIComponent on the server and decodeURIComponent on the client before JSON.parse. * fix: Update file route tests after dev merge --------- Co-authored-by: Danny Avila <danny@librechat.ai>
This commit is contained in:
parent
5c338a4642
commit
5efbcb8b93
3 changed files with 18 additions and 11 deletions
|
|
@ -96,7 +96,9 @@ export const useFileDownload = (
|
|||
const blob = response.data;
|
||||
const downloadURL = window.URL.createObjectURL(blob);
|
||||
try {
|
||||
const metadata: t.TFile | undefined = JSON.parse(response.headers['x-file-metadata']);
|
||||
const metadata: t.TFile | undefined = JSON.parse(
|
||||
decodeURIComponent(response.headers['x-file-metadata']),
|
||||
);
|
||||
if (!metadata) {
|
||||
console.warn('No metadata found for file download', response.headers);
|
||||
return downloadURL;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue