Skip to content

Commit c3fc4f8

Browse files
committed
Round GenNumMax; typecast reader crypt(0 attribute
1 parent 1572c21 commit c3fc4f8

File tree

3 files changed

+13
-13
lines changed

3 files changed

+13
-13
lines changed

coverage/PDF/IO/Crypt/AST.rakucov

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
1-
✱ use v6;
2-
3-
x unit role PDF::IO::Crypt::AST;
1+
* unit role PDF::IO::Crypt::AST;
42

53
x method crypt {...}
64
x method EncryptMetadata {...}
@@ -45,8 +43,8 @@ x || (.key eq 'Metadata' && ! $.EncryptMetadata);
4543
* multi method crypt-ast('dict', SignatureDictLike $ast, |c) {
4644
# skip encryption of the /Contents entry of a Signature
4745
# dictionary, if it's a hex string.
48-
* for $ast.pairs.sort {
49-
* $.crypt-ast(.value, |c)
46+
x for $ast.pairs.sort {
47+
x $.crypt-ast(.value, |c)
5048
unless .key eq 'Contents' && .value ~~ :hex-string;
5149
}
5250
}

coverage/PDF/IO/Reader.rakucov

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use PDF::Grammar::PDF;
77
use PDF::Grammar::PDF::Actions;
88
use PDF::IO;
9+
use PDF::IO::Crypt::PDF;
910
use PDF::IO::IndObj;
1011
use PDF::IO::Serializer;
1112
use PDF::COS :IndRef, :IndObj;
@@ -17,7 +18,7 @@
1718
use JSON::Fast;
1819
use Method::Also;
1920

20-
constant GenNumMax = 65_536;
21+
constant GenNumMax = 100_000;
2122

2223
subset ObjNumInt of UInt;
2324
subset GenNumInt of Int where 0 <= * < GenNumMax;
@@ -32,7 +33,7 @@
3233
has uint64 $.prev; #= xref offset
3334
has uint $.size is rw; #= /Size entry in trailer dict ~ first free object number
3435
has uint64 @.xrefs = (0); #= xref position for each revision in the file
35-
has $.crypt is rw;
36+
has PDF::IO::Crypt::PDF $.crypt is rw;
3637
has Rat $.compat; #= cross reference stream mode
3738
* method compat is rw {
3839
* Proxy.new:
@@ -606,11 +607,11 @@ x elsif $type == IndexType::External {
606607

607608
my UInt @ends;
608609
✱ my UInt $offset = $!prev;
609-
✱ my UInt %offsets-seen;
610+
✱ my UInt %visited;
610611

611612
x while $offset.defined {
612613
* die "xref '/Prev' cycle detected in cross-reference tables: \@$offset"
613-
if %offsets-seen{$offset}++;
614+
if %visited{$offset}++;
614615
* @!xrefs.unshift: $offset;
615616
* $offset = self!load-xref-section: $offset, :@ends;
616617
}

lib/PDF/IO/Reader.rakumod

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use PDF::Grammar::COS;
66
use PDF::Grammar::PDF;
77
use PDF::Grammar::PDF::Actions;
88
use PDF::IO;
9+
use PDF::IO::Crypt::PDF;
910
use PDF::IO::IndObj;
1011
use PDF::IO::Serializer;
1112
use PDF::COS :IndRef, :IndObj;
@@ -17,7 +18,7 @@ use Hash::int;
1718
use JSON::Fast;
1819
use Method::Also;
1920

20-
constant GenNumMax = 65_536;
21+
constant GenNumMax = 100_000;
2122

2223
subset ObjNumInt of UInt;
2324
subset GenNumInt of Int where 0 <= * < GenNumMax;
@@ -32,7 +33,7 @@ has Str $.type is rw; #= 'PDF', 'FDF', etc...
3233
has uint64 $.prev; #= xref offset
3334
has uint $.size is rw; #= /Size entry in trailer dict ~ first free object number
3435
has uint64 @.xrefs = (0); #= xref position for each revision in the file
35-
has $.crypt is rw;
36+
has PDF::IO::Crypt::PDF $.crypt is rw;
3637
has Rat $.compat; #= cross reference stream mode
3738
method compat is rw {
3839
Proxy.new:
@@ -606,11 +607,11 @@ method !load-xrefs($grammar, $actions, |c) {
606607

607608
my UInt @ends;
608609
my UInt $offset = $!prev;
609-
my UInt %offsets-seen;
610+
my UInt %visited;
610611

611612
while $offset.defined {
612613
die "xref '/Prev' cycle detected in cross-reference tables: \@$offset"
613-
if %offsets-seen{$offset}++;
614+
if %visited{$offset}++;
614615
@!xrefs.unshift: $offset;
615616
$offset = self!load-xref-section: $offset, :@ends;
616617
}

0 commit comments

Comments
 (0)