mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-12 19:25:47 +02:00
This commit changes the `JpxImage.decode` method signature to define the `ignoreColorSpace` argument as optional with a default value. Note that we already set this default value in the `getBytes` method of the `src/core/decode_stream.js` file since this option only seems useful for certain special cases and therefore shouldn't be mandatory to provide. Moreover, the JPX fuzzer is changed to use the new `JpxImage` API.
29 lines
616 B
JavaScript
29 lines
616 B
JavaScript
import {
|
|
JpxImage,
|
|
setVerbosityLevel,
|
|
VerbosityLevel,
|
|
} from "../../build/image_decoders/pdf.image_decoders.mjs";
|
|
|
|
// Avoid unnecessary console "spam", by ignoring `info`/`warn` calls.
|
|
setVerbosityLevel(VerbosityLevel.ERRORS);
|
|
|
|
const ignored = ["Cannot read properties", "JPX error"];
|
|
|
|
function ignoredError(error) {
|
|
return ignored.some(message => error.message.includes(message));
|
|
}
|
|
|
|
/**
|
|
* @param {Buffer} data
|
|
*/
|
|
function fuzz(data) {
|
|
try {
|
|
JpxImage.decode(new Uint8Array(data));
|
|
} catch (error) {
|
|
if (error.message && !ignoredError(error)) {
|
|
throw error;
|
|
}
|
|
}
|
|
}
|
|
|
|
export { fuzz };
|