Skip to content
Permalink
Browse files

Fix #74

  • Loading branch information...
hhrutter committed Apr 3, 2019
1 parent e8cee97 commit 40f60a0a25c5359e3d44c06138404079ae272622
Showing with 32 additions and 1 deletion.
  1. +10 −1 pkg/pdfcpu/validate/info.go
  2. +22 −0 pkg/pdfcpu/xreftable.go
@@ -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 {
@@ -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
}
@@ -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) {

0 comments on commit 40f60a0

Please sign in to comment.
You can’t perform that action at this time.