fix: bound document extraction

This commit is contained in:
lofyer
2026-08-13 04:46:30 +08:00
parent 5b579ae100
commit e3b5702767
13 changed files with 1106 additions and 194 deletions
+17
View File
@@ -99,6 +99,23 @@ export class DocumentOcrBroker {
return
}
if (result.success) {
if (
pending.request.mimeType === 'application/pdf' &&
result.data.sections.some(
(section) =>
section.pageNumber === undefined ||
section.pageNumber > result.data.pageCount ||
(
pending.request.pageNumbers !== undefined &&
!pending.request.pageNumbers.includes(section.pageNumber)
)
)
) {
this.finishRequest(requestId, () =>
pending.reject(new Error('OCR 响应页码无效'))
)
return
}
this.finishRequest(requestId, () =>
pending.resolve(result.data)
)