Merge pull request #13105 from Snuffleupagus/BasePdfManager-parseDocBaseUrl

Improve memory usage around the `BasePdfManager.docBaseUrl` parameter (PR 7689 follow-up)
This commit is contained in:
Tim van der Meij 2021-03-19 23:03:20 +01:00 committed by GitHub
commit 8269ddbd16
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
10 changed files with 251 additions and 244 deletions

View file

@ -40,6 +40,7 @@ import {
deprecated,
DOMCanvasFactory,
DOMCMapReaderFactory,
isDataScheme,
loadScript,
PageViewport,
RenderingCancelledException,
@ -288,6 +289,15 @@ function getDocument(src) {
params.pdfBug = params.pdfBug === true;
params.enableXfa = params.enableXfa === true;
if (
typeof params.docBaseUrl !== "string" ||
isDataScheme(params.docBaseUrl)
) {
// Ignore "data:"-URLs, since they can't be used to recover valid absolute
// URLs anyway. We want to avoid sending them to the worker-thread, since
// they contain the *entire* PDF document and can thus be arbitrarily long.
params.docBaseUrl = null;
}
if (!Number.isInteger(params.maxImageSize)) {
params.maxImageSize = -1;
}