Skip to content

Commit

Permalink
expand relaxed validation for outlines
Browse files Browse the repository at this point in the history
  • Loading branch information
cameroncaci committed Feb 4, 2025
1 parent 787ebed commit 1a00605
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion pkg/pdfcpu/validate/xReftable.go
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ func validateRootObject(ctx *model.Context) error {
{validateCollection, OPTIONAL, model.V17},
{validateNeedsRendering, OPTIONAL, model.V17},
} {
if !f.required && xRefTable.Version() < f.sinceVersion {
if !f.required && xRefTable.Version() < f.sinceVersion || isValidateOutlines(f.validate) {
// Ignore optional fields if currentVersion < sinceVersion
// This is really a workaround for explicitly extending relaxed validation.
continue
Expand All @@ -1079,6 +1079,11 @@ func validateRootObject(ctx *model.Context) error {
return err
}

// Helper func to compare two funcs, go doesn't allow direct comparisons
func isValidateOutlines(f func(*model.XRefTable, types.Dict, bool, model.Version) error) bool {
return fmt.Sprintf("%p", f) == fmt.Sprintf("%p", validateOutlines)
}

func validateAdditionalStreams(xRefTable *model.XRefTable) error {
// Out of spec scope.
return nil
Expand Down

0 comments on commit 1a00605

Please sign in to comment.