mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-02 20:37:21 +02: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() {
|
get filename() {
|
||||||
const item = pickPlatformItem(this.root);
|
const item = pickPlatformItem(this.root);
|
||||||
let name;
|
|
||||||
if (item && typeof item === "string") {
|
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("\\/", "/")
|
.replaceAll("\\/", "/")
|
||||||
.replaceAll("\\", "/");
|
.replaceAll("\\", "/");
|
||||||
}
|
}
|
||||||
return name || "unnamed";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
get content() {
|
get content() {
|
||||||
@ -100,7 +101,7 @@ class FileSpec {
|
|||||||
const { filename, content, description } = this;
|
const { filename, content, description } = this;
|
||||||
return {
|
return {
|
||||||
rawFilename: filename,
|
rawFilename: filename,
|
||||||
filename: stripPath(filename),
|
filename: stripPath(filename) || "unnamed",
|
||||||
content,
|
content,
|
||||||
description,
|
description,
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user