Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix CVE-2024-4367 #935

Merged
merged 2 commits into from
May 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions imports/lib/pdf/pdf.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
import {type DocumentInitParameters} from 'pdfjs-dist/types/src/display/api';

export {type DocumentInitParameters} from 'pdfjs-dist/types/src/display/api';
export {type PageViewport} from 'pdfjs-dist/types/src/display/display_utils';

export const WORKER_URL = Meteor.isClient
? '/pdfjs-dist/build/pdf.worker.min.js'
: 'pdfjs-dist/legacy/build/pdf.worker.js';
Expand All @@ -15,6 +18,7 @@
cMapUrl = CMAP_URL,
cMapPacked = CMAP_PACKED,
standardFontDataUrl = STANDARD_FONT_DATA_URL,
isEvalSupported = false,
...rest
}: DocumentInitParameters) {
const pdfjs = Meteor.isClient
Expand All @@ -27,8 +31,13 @@
// pdfjs.GlobalWorkerOptions.workerSrc = `//cdnjs.cloudflare.com/ajax/libs/pdf.js/${pdfjs.version}/pdf.worker.js`;
}

return pdfjs.getDocument({cMapUrl, cMapPacked, standardFontDataUrl, ...rest})
.promise;
return pdfjs.getDocument({
cMapUrl,
cMapPacked,

Check warning on line 36 in imports/lib/pdf/pdf.ts

View check run for this annotation

Codecov / codecov/patch

imports/lib/pdf/pdf.ts#L36

Added line #L36 was not covered by tests
standardFontDataUrl,
isEvalSupported,
...rest,
}).promise;

Check warning on line 40 in imports/lib/pdf/pdf.ts

View check run for this annotation

Codecov / codecov/patch

imports/lib/pdf/pdf.ts#L40

Added line #L40 was not covered by tests
}

export async function saveHTMLElementAsPDF(
Expand Down
4 changes: 1 addition & 3 deletions imports/lib/pdf/pdfthumbnails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,10 @@ import {
type PngConfig,
} from 'canvas/types';
import addDays from 'date-fns/addDays';
import {type DocumentInitParameters} from 'pdfjs-dist/types/src/display/api';
import {type PageViewport} from 'pdfjs-dist/types/src/display/display_utils';

import {cache as lru, type IndexedDBPersistedLRUCache} from '../cache/lru';

import {fetchPDF} from './pdf';
import {type DocumentInitParameters, type PageViewport, fetchPDF} from './pdf';

let cache: IndexedDBPersistedLRUCache<string, string>;
if (Meteor.isClient) {
Expand Down
Loading