From 05eee50b4ccba432717a1ee3ac17f5815a74e2a8 Mon Sep 17 00:00:00 2001 From: Adrian-George Bostan Date: Thu, 13 Jun 2019 20:37:14 +0300 Subject: [PATCH] Skip invalid Metadata stream in form field Kids array --- model/fields.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/model/fields.go b/model/fields.go index fe6ab29d..13991975 100644 --- a/model/fields.go +++ b/model/fields.go @@ -681,6 +681,15 @@ func (r *PdfReader) newPdfFieldFromIndirectObject(container *core.PdfIndirectObj for _, obj := range kids.Elements() { container, isIndirect := core.GetIndirect(obj) if !isIndirect { + stream, ok := core.GetStream(obj) + if ok && stream.PdfObjectDictionary != nil { + nodeType, ok := core.GetNameVal(stream.Get("Type")) + if ok && nodeType == "Metadata" { + common.Log.Debug("ERROR: form field Kids array contains invalid Metadata stream. Skipping.") + continue + } + } + return nil, errors.New("not an indirect object (form field)") }