mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
Don't get ICC color space files if required API options are missing
This commit improves validation of the API options for the ICC color space logic. If `useWasm` is `true` but the corresponding `wasmUrl` or `iccUrl` API options are not provided we can avoid requesting files with `null` URLs which always results in a 404 response.
This commit is contained in:
parent
d86045eacb
commit
f44cba86d5
2 changed files with 23 additions and 6 deletions
|
@ -289,7 +289,7 @@ class ColorSpaceUtils {
|
|||
}
|
||||
|
||||
static get cmyk() {
|
||||
if (IccColorSpace.isUsable) {
|
||||
if (CmykICCBasedCS.isUsable) {
|
||||
try {
|
||||
return shadow(this, "cmyk", new CmykICCBasedCS());
|
||||
} catch {
|
||||
|
|
|
@ -130,11 +130,15 @@ class IccColorSpace extends ColorSpace {
|
|||
static get isUsable() {
|
||||
let isUsable = false;
|
||||
if (this.#useWasm) {
|
||||
try {
|
||||
this._module = QCMS._module = this.#load();
|
||||
isUsable = !!this._module;
|
||||
} catch (e) {
|
||||
warn(`ICCBased color space: "${e}".`);
|
||||
if (this.#wasmUrl) {
|
||||
try {
|
||||
this._module = QCMS._module = this.#load();
|
||||
isUsable = !!this._module;
|
||||
} catch (e) {
|
||||
warn(`ICCBased color space: "${e}".`);
|
||||
}
|
||||
} else {
|
||||
warn("No ICC color space support due to missing `wasmUrl` API option");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,6 +173,19 @@ class CmykICCBasedCS extends IccColorSpace {
|
|||
static setOptions({ iccUrl }) {
|
||||
this.#iccUrl = iccUrl;
|
||||
}
|
||||
|
||||
static get isUsable() {
|
||||
let isUsable = false;
|
||||
if (IccColorSpace.isUsable) {
|
||||
if (this.#iccUrl) {
|
||||
isUsable = true;
|
||||
} else {
|
||||
warn("No CMYK ICC profile support due to missing `iccUrl` API option");
|
||||
}
|
||||
}
|
||||
|
||||
return shadow(this, "isUsable", isUsable);
|
||||
}
|
||||
}
|
||||
|
||||
export { CmykICCBasedCS, IccColorSpace };
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue