Browse Source

Fixed download file name for files with quotes in the name

getFilenameFromHttpHeader stopped at the first quote inside filename="...", so a file named a"b.png was saved as a\. It now reads the full quoted string and unescapes it.
pull/16637/head
Ekaterina Chantsova 3 weeks ago
parent
commit
437283b1d9
  1. 4
      ui-ngx/src/app/core/utils.ts

4
ui-ngx/src/app/core/utils.ts

@ -1240,9 +1240,9 @@ export const getFilenameFromHttpHeader = (headers: HttpHeaders): string => {
if (filenameStarMatch && filenameStarMatch[1]) {
return decodeURIComponent(filenameStarMatch[1]);
}
const filenameMatch = /filename="([^"]+)"/i.exec(header);
const filenameMatch = /filename="((?:[^"\\]|\\.)+)"/i.exec(header);
if (filenameMatch && filenameMatch[1]) {
return filenameMatch[1];
return filenameMatch[1].replace(/\\(.)/g, '$1');
}
}
return headers.get('x-filename') ?? '';

Loading…
Cancel
Save