Skip to content

Commit

Permalink
Fix #74
Browse files Browse the repository at this point in the history
  • Loading branch information
hhrutter committed Apr 3, 2019
1 parent e8cee97 commit 40f60a0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
11 changes: 10 additions & 1 deletion pkg/pdfcpu/validate/info.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func validateInfoDictDate(xRefTable *pdf.XRefTable, o pdf.Object) (err error) {

func validateInfoDictTrapped(o pdf.Object, xRefTable *pdf.XRefTable) error {

sinceVersion := pdf.V13

validate := func(s string) bool { return pdf.MemberOf(s, []string{"True", "False", "Unknown"}) }

if xRefTable.ValidationMode == pdf.ValidationRelaxed {
Expand All @@ -54,7 +56,14 @@ func validateInfoDictTrapped(o pdf.Object, xRefTable *pdf.XRefTable) error {
}
}

_, err := xRefTable.DereferenceName(o, pdf.V13, validate)
_, err := xRefTable.DereferenceName(o, sinceVersion, validate)
if err == nil {
return nil
}

if xRefTable.ValidationMode == pdf.ValidationRelaxed {
_, err = xRefTable.DereferenceBoolean(o, sinceVersion)
}

return err
}
Expand Down
22 changes: 22 additions & 0 deletions pkg/pdfcpu/xreftable.go
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,28 @@ func (xRefTable *XRefTable) Dereference(o Object) (Object, error) {
return xRefTable.indRefToObject(&ir)
}

// DereferenceBoolean resolves and validates a boolean object, which may be an indirect reference.
func (xRefTable *XRefTable) DereferenceBoolean(o Object, sinceVersion Version) (*Boolean, error) {

o, err := xRefTable.Dereference(o)
if err != nil || o == nil {
return nil, err
}

b, ok := o.(Boolean)
if !ok {
return nil, errors.Errorf("DereferenceBoolean: wrong type <%v>", o)
}

// Version check
err = xRefTable.ValidateVersion("DereferenceBoolean", sinceVersion)
if err != nil {
return nil, err
}

return &b, nil
}

// DereferenceInteger resolves and validates an integer object, which may be an indirect reference.
func (xRefTable *XRefTable) DereferenceInteger(o Object) (*Integer, error) {

Expand Down

0 comments on commit 40f60a0

Please sign in to comment.