mirror of
https://github.com/laurent22/joplin.git
synced 2024-11-24 08:12:24 +02:00
Desktop: Disable eval in pdf.js (#10450)
This commit is contained in:
parent
3312bd27c9
commit
9fcaf5bd18
@ -736,8 +736,16 @@ function shimInit(options: ShimInitOptions = null) {
|
||||
}
|
||||
};
|
||||
|
||||
const getPdfJsDocument = (path: string) => {
|
||||
return pdfJs.getDocument({
|
||||
url: path,
|
||||
// IMPORTANT: Set to false to mitigate CVE-2024-4367.
|
||||
isEvalSupported: false,
|
||||
});
|
||||
};
|
||||
|
||||
shim.pdfExtractEmbeddedText = async (pdfPath: string): Promise<string[]> => {
|
||||
const loadingTask = pdfJs.getDocument(pdfPath);
|
||||
const loadingTask = getPdfJsDocument(pdfPath);
|
||||
const doc = await loadingTask.promise;
|
||||
const textByPage = [];
|
||||
|
||||
@ -791,7 +799,7 @@ function shimInit(options: ShimInitOptions = null) {
|
||||
|
||||
const filePrefix = `page_${Date.now()}`;
|
||||
const output: string[] = [];
|
||||
const loadingTask = pdfJs.getDocument(pdfPath);
|
||||
const loadingTask = getPdfJsDocument(pdfPath);
|
||||
const doc = await loadingTask.promise;
|
||||
|
||||
try {
|
||||
|
@ -20,9 +20,9 @@ export default class PdfDocument {
|
||||
this.rendererMutex = withTimeout(new Mutex(), 40 * 1000);
|
||||
}
|
||||
|
||||
public loadDoc = async (url: string | Uint8Array) => {
|
||||
public loadDoc = async (url: string) => {
|
||||
this.url = url;
|
||||
const loadingTask = pdfjsLib.getDocument(url);
|
||||
const loadingTask = pdfjsLib.getDocument({ url, isEvalSupported: false });
|
||||
try {
|
||||
const pdfDocument: any = await loadingTask.promise;
|
||||
this.doc = pdfDocument;
|
||||
|
Loading…
Reference in New Issue
Block a user