Skip to content

Commit 106feff

Browse files
committed
Fix #1116, clean up
1 parent f11409b commit 106feff

File tree

3 files changed

+5
-70
lines changed

3 files changed

+5
-70
lines changed

pkg/pdfcpu/model/configuration.go

Lines changed: 0 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -522,73 +522,6 @@ func NewRC4Configuration(userPW, ownerPW string, keyLength int) *Configuration {
522522
return c
523523
}
524524

525-
// func (c Configuration) String() string {
526-
// path := "default"
527-
// if len(c.Path) > 0 {
528-
// path = c.Path
529-
// }
530-
// return fmt.Sprintf("pdfcpu configuration:\n"+
531-
// "Path: %s\n"+
532-
// "CreationDate: %s\n"+
533-
// "Version: %s\n"+
534-
// "CheckFileNameExt: %t\n"+
535-
// "Reader15: %t\n"+
536-
// "DecodeAllStreams: %t\n"+
537-
// "ValidationMode: %s\n"+
538-
// "PostProcessValidate: %t\n"+
539-
// "ValidateLinks: %t\n"+
540-
// "Eol: %s\n"+
541-
// "WriteObjectStream: %t\n"+
542-
// "WriteXrefStream: %t\n"+
543-
// "EncryptUsingAES: %t\n"+
544-
// "EncryptKeyLength: %d\n"+
545-
// "Permissions: %d\n"+
546-
// "Unit: %s\n"+
547-
// "TimestampFormat: %s\n"+
548-
// "DateFormat: %s\n"+
549-
// "Optimize: %t\n"+
550-
// "OptimizeBeforeWriting: %t\n"+
551-
// "OptimizeResourceDicts: %t\n"+
552-
// "OptimizeDuplicateContentStreams %t\n"+
553-
// "CreateBookmarks: %t\n"+
554-
// "NeedAppearances: %t\n"+
555-
// "Offline: %t\n"+
556-
// "Timeout: %d\n"+
557-
// "TimeoutCRL: %d\n"+
558-
// "TimeoutOCSP: %d\n"+
559-
// "PrefCertRevChecker: %s\n",
560-
// path,
561-
// c.CreationDate,
562-
// c.Version,
563-
// c.CheckFileNameExt,
564-
// c.Reader15,
565-
// c.DecodeAllStreams,
566-
// c.ValidationModeString(),
567-
// c.PostProcessValidate,
568-
// c.ValidateLinks,
569-
// c.EolString(),
570-
// c.WriteObjectStream,
571-
// c.WriteXRefStream,
572-
// c.EncryptUsingAES,
573-
// c.EncryptKeyLength,
574-
// c.Permissions,
575-
// c.UnitString(),
576-
// c.TimestampFormat,
577-
// c.DateFormat,
578-
// c.Optimize,
579-
// c.OptimizeBeforeWriting,
580-
// c.OptimizeResourceDicts,
581-
// c.OptimizeDuplicateContentStreams,
582-
// c.CreateBookmarks,
583-
// c.NeedAppearances,
584-
// c.Offline,
585-
// c.Timeout,
586-
// c.TimeoutCRL,
587-
// c.TimeoutOCSP,
588-
// c.PreferredCertRevocationCheckerString(),
589-
// )
590-
// }
591-
592525
// EolString returns a string rep for the eol in effect.
593526
func (c *Configuration) EolString() string {
594527
var s string

pkg/pdfcpu/types/streamdict.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ func (sd *StreamDict) DecodeLength(maxLen int64) ([]byte, error) {
426426

427427
// IndexedObject returns the object at given index from a ObjectStreamDict.
428428
func (osd *ObjectStreamDict) IndexedObject(index int) (Object, error) {
429-
if osd.ObjArray == nil {
429+
if osd.ObjArray == nil || index < 0 || index >= len(osd.ObjArray) {
430430
return nil, errors.Errorf("IndexedObject(%d): object not available", index)
431431
}
432432
return osd.ObjArray[index], nil

pkg/pdfcpu/validate/nameTree.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -720,7 +720,10 @@ func validateNameTree(xRefTable *model.XRefTable, name string, d types.Dict, roo
720720
}
721721

722722
if len(a) == 0 {
723-
return "", "", nil, errors.New("pdfcpu: validateNameTree: missing \"Kids\" array")
723+
if xRefTable.ValidationMode == model.ValidationStrict {
724+
return "", "", nil, errors.New("pdfcpu: validateNameTree: missing \"Kids\" array")
725+
}
726+
return "", "", nil, nil
724727
}
725728

726729
for _, o := range a {
@@ -738,7 +741,6 @@ func validateNameTree(xRefTable *model.XRefTable, name string, d types.Dict, roo
738741
return "", "", nil, err
739742
}
740743
continue
741-
//return kmin, kmax, nil, nil
742744
}
743745
if kmin == "" {
744746
kmin = kminKid

0 commit comments

Comments
 (0)