Skip to content

Commit b3f35b6

Browse files
committed
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.
1 parent 640a310 commit b3f35b6

1 file changed

Lines changed: 5 additions & 4 deletions

File tree

src/core/file_spec.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ class FileSpec {
6565

6666
get filename() {
6767
const item = pickPlatformItem(this.root);
68-
let name;
6968
if (item && typeof item === "string") {
70-
name = stringToPDFString(item, /* keepEscapeSequence = */ true)
69+
// NOTE: The following replacement order is INTENTIONAL, regardless of
70+
// what some static code analysers (e.g. CodeQL) may claim.
71+
return stringToPDFString(item, /* keepEscapeSequence = */ true)
7172
.replaceAll("\\\\", "\\")
7273
.replaceAll("\\/", "/")
7374
.replaceAll("\\", "/");
7475
}
75-
return name || "unnamed";
76+
return "";
7677
}
7778

7879
get content() {
@@ -100,7 +101,7 @@ class FileSpec {
100101
const { filename, content, description } = this;
101102
return {
102103
rawFilename: filename,
103-
filename: stripPath(filename),
104+
filename: stripPath(filename) || "unnamed",
104105
content,
105106
description,
106107
};

0 commit comments

Comments
 (0)