1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 15:18:08 +02:00

Prevent textLayer errors in documents with unbalanced beginMarkedContent/endMarkedContent operators (issue 15629)

This commit is contained in:
Jonas Jenwald 2022-10-26 17:59:48 +02:00
parent 9a33a0fba9
commit 980acddbfa
4 changed files with 17 additions and 1 deletions

View file

@ -224,6 +224,8 @@ function render(task) {
}
class TextLayerRenderTask {
#initialContainer = null;
constructor({
textContent,
textContentStream,
@ -235,6 +237,7 @@ class TextLayerRenderTask {
this._textContent = textContent;
this._textContentStream = textContentStream;
this._container = container;
this.#initialContainer = container;
this._document = container.ownerDocument;
this._viewport = viewport;
this._textDivs = textDivs || [];
@ -318,7 +321,13 @@ class TextLayerRenderTask {
}
parent.append(this._container);
} else if (item.type === "endMarkedContent") {
this._container = this._container.parentNode;
const parent = this._container.parentNode;
if (!parent || this._container === this.#initialContainer) {
// Handle unbalanced beginMarkedContent/endMarkedContent operators
// (fixes issue15629.pdf).
continue;
}
this._container = parent;
}
continue;
}