Prevent textLayer errors in documents with unbalanced beginMarkedContent/endMarkedContent operators (issue 15629)
This commit is contained in:
parent
9a33a0fba9
commit
980acddbfa
@ -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;
|
||||
}
|
||||
|
1
test/pdfs/.gitignore
vendored
1
test/pdfs/.gitignore
vendored
@ -302,6 +302,7 @@
|
||||
!issue5751.pdf
|
||||
!bug893730.pdf
|
||||
!bug864847.pdf
|
||||
!issue15629.pdf
|
||||
!issue1002.pdf
|
||||
!issue925.pdf
|
||||
!issue2840.pdf
|
||||
|
BIN
test/pdfs/issue15629.pdf
Normal file
BIN
test/pdfs/issue15629.pdf
Normal file
Binary file not shown.
@ -2263,6 +2263,12 @@
|
||||
"rounds": 1,
|
||||
"type": "eq"
|
||||
},
|
||||
{ "id": "issue15629",
|
||||
"file": "pdfs/issue15629.pdf",
|
||||
"md5": "689771b7f5c86c783c56aa8dedab0057",
|
||||
"rounds": 1,
|
||||
"type": "text"
|
||||
},
|
||||
{ "id": "glyph_accent",
|
||||
"file": "pdfs/glyph_accent.pdf",
|
||||
"md5": "1526e4edaa3ec439ebf156d0a0b385aa",
|
||||
|
Loading…
Reference in New Issue
Block a user