mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-02-08 00:21:11 +01:00
Return the rawFilename as-is even if it's empty, from FileSpec.prototype.serializable
It's more correct to return the `rawFilename` as-is, and limit the fallback for empty filenames to only the `filename` property.
This commit is contained in:
parent
640a3106d5
commit
b3f35b6007
@ -65,14 +65,15 @@ class FileSpec {
|
||||
|
||||
get filename() {
|
||||
const item = pickPlatformItem(this.root);
|
||||
let name;
|
||||
if (item && typeof item === "string") {
|
||||
name = stringToPDFString(item, /* keepEscapeSequence = */ true)
|
||||
// NOTE: The following replacement order is INTENTIONAL, regardless of
|
||||
// what some static code analysers (e.g. CodeQL) may claim.
|
||||
return stringToPDFString(item, /* keepEscapeSequence = */ true)
|
||||
.replaceAll("\\\\", "\\")
|
||||
.replaceAll("\\/", "/")
|
||||
.replaceAll("\\", "/");
|
||||
}
|
||||
return name || "unnamed";
|
||||
return "";
|
||||
}
|
||||
|
||||
get content() {
|
||||
@ -100,7 +101,7 @@ class FileSpec {
|
||||
const { filename, content, description } = this;
|
||||
return {
|
||||
rawFilename: filename,
|
||||
filename: stripPath(filename),
|
||||
filename: stripPath(filename) || "unnamed",
|
||||
content,
|
||||
description,
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user