Branch Coverage

blib/lib/Image/ExifTool/PDF.pm
Criterion Covered Total %
branch 289 724 39.9


line true false branch
579 0 10 if (length $date < length $default)
582 0 10 unless $date =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(.*)/
584 10 0 if ($7)
586 0 10 if ($tz =~ /^\s*Z/i) { }
10 0 elsif ($tz =~ /^\s*([-+])\s*(\d+)[': ]+(\d*)/) { }
605 0 238 unless $xref
606 231 7 if exists $xref->{$ref}
608 0 7 unless $ref =~ /^(\d+)/
611 6 1 if defined $xref->{$objNum}
615 1 0 unless $xref->{'dicts'}
619 0 0 if $objNum >= $dict->{'Size'}
621 0 0 if $objNum < $index->[0]
631 0 0 if $objNum < $start
632 0 0 if ($objNum < $start + $count)
634 0 0 if $offset + $size > length $dict->{'_stream'}
643 0 0 $j ? :
0 0 unless $w->[$j]
652 0 0 if ($t[0] == 1) { }
0 0 elsif ($t[0] == 2) { }
0 0 elsif ($t[0] == 0) { }
670 0 0 if $ref eq $ref2
688 0 41 if $offset and $offset =~ /^I/
702 0 217 unless $raf->Seek($offset + $et->{'PDFBase'}, 0)
706 0 217 unless $raf->ReadLine($data)
707 217 0 if $data =~ s/^$obj//
708 0 0 if $data =~ /^\s+$/
715 0 0 unless ($data =~ s/$pat//)
724 217 217 if $data =~ /\S/ and not $data =~ /^\s*%/
725 0 217 unless $raf->ReadLine($data)
743 5 192 unless ($offset)
744 0 5 unless defined $offset
748 0 192 if ($offset =~ s/^I(\d+) //)
753 0 0 unless ($obj)
755 0 0 if defined $obj
760 0 0 unless defined $obj and ref $obj eq "HASH"
761 0 0 unless $obj->{'First'} and $obj->{'N'}
762 0 0 unless &DecodeStream($et, $obj)
767 0 0 unless @table == $num
778 0 0 unless ($index < $obj->{'N'} and $table->[$i] == $objNum)
789 0 0 if $cryptStream
794 0 192 unless defined $data
807 12 136 if (ref $str eq "ARRAY")
815 0 136 unless length $str
817 58 78 if ($delim eq '(') { }
41 37 elsif ($delim eq '<') { }
0 37 elsif ($delim eq '/') { }
818 58 0 if $str =~ /^.*?\((.*)\)/s
824 0 0 if ($c =~ /[0-7]/) { }
0 0 elsif ($c eq "\r") { }
0 0 elsif ($c eq "\n") { }
826 0 0 if $str =~ /\G([0-7]{1,2})/g
832 0 0 if $str =~ /\G(\x0a)/g
844 0 58 if $cryptString
848 0 41 if length $str & 1
850 12 29 if $cryptString
854 0 0 if $pdfVer >= "1.2"
880 754 70 if ($$dataPt =~ /^\s*(<{1,2}|\[|\()/s) { }
0 70 elsif ($$dataPt =~ s<^\s*(\S[^[(/<>\s]*)\s*>[]s) { }
884 0 754 unless defined $objData
892 0 0 if ($objData =~ /^\d+$/ and $$dataPt =~ s/^(\d+)\s+R//s)
898 0 70 unless $raf and $raf->ReadLine($data)
904 160 594 if ($delim eq '(' or $delim eq '<') { }
167 427 elsif ($delim eq '[') { }
910 0 167 unless $objData =~ /^.*?\[(.*)\]/s
914 167 427 unless $data =~ m<\s*(\S[^[(/<>\s]*)>gs
916 78 349 if ($val =~ /^(<{1,2}|\[|\()/) { }
245 104 elsif ($val =~ /^\d/) { }
921 0 78 unless defined $val
926 37 208 if ($data =~ /\G\s+(\d+)\s+R/g) { }
946 396 833 if ($val =~ /^(<{1,2}|\[|\()/) { }
618 215 elsif ($val =~ /^\d/) { }
950 0 396 unless defined $val
955 416 202 if ($objData =~ /\G\s+(\d+)\s+R/gs) { }
961 0 1229 if ($dict->{$tag}) { }
970 0 427 unless @tags
972 165 262 unless $raf
977 219 43 unless my $length = $dict->{'Length'}
978 25 18 if (ref $length)
983 0 25 unless my $offset = &LocateObject($xref, $length)
984 0 25 unless $offset
986 0 25 unless defined $data
987 0 25 unless $data =~ /^\s*(\d+)/
994 43 43 if ($$dataPt =~ /(\S+)/)
995 0 43 unless $1 eq "stream"
997 43 0 if $raf->ReadLine($data)
1001 28 15 if ($more > 0) { }
15 0 elsif ($more < 0) { }
1002 0 28 unless ($raf->Read($data, $more) == $more)
1018 0 43 unless $raf->ReadLine($data)
1042 1148 4596 unless ($$dataPt =~ /(\\*)(\(|\)|<{1,2}|>{1,2}|\[|\]|%)/g)
1045 0 1148 unless $raf and $raf->ReadLine($buff)
1051 434 4162 if ($delim[0] eq ')') { }
0 4162 elsif ($2 eq '%') { }
1053 0 434 if length $1 & 1
1055 0 434 unless $2 eq "(" or $2 eq ")"
1066 2298 2298 if ($closingDelim{$2})
1071 0 2298 unless ($2 eq $delim[0])
1074 0 0 unless $2 eq ">>" and $delim[0] eq ">"
1078 1070 1228 if $delim[0]
1094 0 0 if length $$dataPt < 4
1104 0 0 if ($shift < 0)
1105 0 0 if $pos >= @dat
1113 0 0 if (defined $val) { }
0 0 elsif ($code == @lzw) { }
0 0 elsif ($code == 256) { }
0 0 elsif ($code == 257) { }
1115 0 0 if defined $lastVal
1117 0 0 unless defined $lastVal
1137 0 0 if @lzw >= $mask and $bits < 12
1153 0 43 unless $dict->{'_stream'}
1157 0 43 if (ref $dict->{'Filter'} eq 'ARRAY') { }
0 43 elsif (defined $dict->{'Filter'}) { }
1164 0 0 if $supportedFilter{$filter}
1171 43 0 unless (defined $dict->{'_decrypted'} or $filters[0] and $filters[0] eq "/Crypt")
1174 43 0 unless $dict->{'Filter'}
1175 0 0 if defined $dict->{'_filtered'}
1179 0 0 if (ref $dict->{'DecodeParms'} eq 'ARRAY') { }
1188 0 0 if ($filter eq '/FlateDecode') { }
0 0 elsif ($filter eq '/Crypt') { }
0 0 elsif ($filter eq '/LZWDecode') { }
0 0 elsif ($filter eq '/ASCIIHexDecode') { }
0 0 elsif ($filter eq '/ASCII85Decode') { }
1191 0 0 if (ref $decodeParms eq "HASH")
1193 0 0 if ($pre and $pre ne 1 and $pre ne 12)
1198 0 0 if (eval { do { require Compress::Zlib } }) { }
1201 0 0 if $inflate
1202 0 0 if ($inflate and $stat == Compress::Zlib::Z_STREAM_END()) { }
1212 0 0 unless $pre and $pre eq 12
1216 0 0 unless ($cols)
1225 0 0 unless (($_ = shift @bytes) == 2)
1240 0 0 if defined $dict->{'_decrypted'}
1242 0 0 unless ref $decodeParms eq "HASH"
1244 0 0 unless defined $name or $name eq "Identity"
1245 0 0 if ($name ne "StdCF")
1249 0 0 unless ($cryptInfo)
1261 0 0 $cryptStream ? :
1266 0 0 if (ref $decodeParms eq "HASH")
1267 0 0 if ($decodeParms->{'Predictor'}) { }
0 0 elsif ($decodeParms->{'EarlyChange'}) { }
1275 0 0 unless (&DecodeLZW(\$dict->{'_stream'}))
1291 0 0 if ($_ ge '!' and $_ le 'u') { }
0 0 elsif ($_ eq '~') { }
0 0 elsif ($_ eq 'z') { }
1293 0 0 unless ++$n == 5
1295 0 0 if $n == 1
1298 0 0 if $n
1301 0 0 if /^\s$/
1309 0 0 if $_ eq "~"
1312 0 0 if $err
1346 22 0 unless ref $key eq "HASH"
1372 0 0 if length $dat
1377 0 0 if ($pos < length $dat) { }
1395 6 0 if $rev == 5
1416 0 0 if length $password
1418 0 0 if length $vector
1419 0 0 if ($j == 0)
1450 0 4 unless ($encrypt and ref $encrypt eq "HASH")
1454 0 4 unless ($filt and $filt =~ s[^/][])
1461 4 0 if $filt eq "Standard"
1462 0 4 if $encrypt->{'SubFilter'} and $encrypt->{'SubFilter'} =~ m[^/(.*)]
1463 4 0 if $filt eq "Standard"
1466 0 4 if ($filt ne 'Standard') { }
0 4 elsif (not defined $encrypt->{'R'}) { }
1471 0 4 unless ($encrypt->{'O'} and $encrypt->{'P'} and $encrypt->{'U'})
1474 0 4 if ("$ver.$rev" >= "5.6")
1482 1 3 if ($ver == 1 or $ver == 2) { }
3 0 elsif ($ver == 4 or $ver == 5) { }
1487 3 3 $_ eq 'StrF' ? :
1489 0 6 if $$flagPt and $$flagPt eq "/Identity"
1490 0 6 if $$flagPt and $$flagPt ne "/StdCF"
1492 3 0 if ($cryptString or $cryptStream)
1494 0 3 unless ref $encrypt->{'CF'} eq "HASH" and ref $encrypt->{'CF'}{'StdCF'} eq "HASH" and $encrypt->{'CF'}{'StdCF'}{'CFM'}
1496 0 3 unless ($cryptMeth =~ m[^/(V2|AESV2|AESV3)$])
1500 3 0 if $cryptMeth =~ m[^/(AESV2|AESV3)$]
1502 2 1 if ($ver == 5)
1505 0 4 unless $encrypt->{$_}
1507 0 4 unless length $parm{$_} == 32
1514 0 4 unless $id
1517 2 2 if ($ver < 5) { }
1518 0 2 unless (eval { do { require Digest::MD5 } })
1522 0 2 unless (eval { do { require Digest::SHA } })
1535 2 1 if ($ver < 4 or not $encrypt->{'EncryptMetadata'} or not $encrypt->{'EncryptMetadata'} =~ /false/i)
1542 4 1 if ($try == 0) { }
1 0 elsif ($try == 1) { }
1546 0 1 unless defined $password
1548 0 1 if ($] >= "5.006" and eval { do { require Encode; &Encode::is_utf8($password) } } || $@)
1550 0 0 $] < 5.01 ? :
0 0 $@ ? :
1555 2 3 if ($ver < 5) { }
1556 0 2 if (length $password) { }
1560 0 0 if (length $password > 32) { }
0 0 elsif (length $password < 32) { }
1570 1 1 if ($rev == 3 or $rev == 4)
1572 1 0 unless $encrypt->{'_meta'}
1576 1 1 if ($ver == 1) { }
1580 0 1 unless $len >= 40
1587 1 1 if ($rev >= 3) { }
1600 2 0 if $dat eq $u
1602 0 3 if length $o < 48 or length $u < 48
1603 1 2 if (length $password)
1608 0 1 if length $password > 127
1612 2 1 if ($sha eq substr($o, 0, 32))
1617 0 2 if $err
1623 0 1 if ($sha eq substr($u, 0, 32))
1627 0 0 if $err
1646 25 4 unless $cryptInfo
1650 0 4 unless defined $keyExt
1653 2 2 unless ($cryptInfo->{'_aesv3'})
1654 2 0 unless ($keyExt eq "none")
1656 0 2 unless ($keyExt =~ /^(I\d+ )?(\d+) (\d+)/)
1666 1 1 if $cryptInfo->{'_aesv2'}
1669 1 1 if $len < 16
1672 3 1 if ($cryptInfo->{'_aesv2'} or $cryptInfo->{'_aesv3'}) { }
1675 0 3 if $err
1686 52 0 unless $cryptStream
1691 0 0 if ($cryptInfo and $type ne '/XRef' and $cryptInfo->{'_meta'} || $type ne '/Metadata') { }
1696 0 0 $dict->{'_decrypted'} ? :
1725 0 0 $dict->{'XFA'} ? :
1738 0 0 if ref $_ eq "SCALAR"
1739 0 0 if ref $_ eq "ARRAY"
1740 0 0 unless defined $_
1761 0 350 if ($nesting > 50)
1766 66 0 if ($et->{'PDF_CAPTURE'} and $tagTablePtr->{'VARS'} and $tagTablePtr->{'VARS'}{'CAPTURE'})
1771 16 66 if $et->{'PDF_CAPTURE'}{$name}
1773 0 66 if $type and $type ne $name
1783 1123 350 if (@tags) { }
0 350 elsif (defined $next and not $next) { }
1793 419 704 if ($tagInfo) { }
0 704 elsif ($embedded and $tag =~ /^(.*?)(\d+)$/ and $tagTablePtr->{$1} and ref $val ne 'SCALAR' || !$fetched{$$val}) { }
1794 0 419 if $tagInfo->{'NoProcess'}
1800 0 0 if (ref $tagInfo eq 'HASH' and $tagInfo->{'JoinStreams'}) { }
1803 0 0 unless $join{$name}
1804 0 0 unless ref $obj eq "HASH" and $obj->{'_stream'}
1813 0 1123 if ($verbose)
1815 0 0 if (ref $val eq 'SCALAR') { }
0 0 elsif (ref $val eq 'HASH') { }
0 0 elsif (ref $val eq 'ARRAY') { }
1817 0 0 if ($fetched{$$val}) { }
0 0 elsif ($tag eq 'Next' and not $next) { }
1826 0 0 unless (defined $val)
1828 0 0 if (defined $lastOffset) { }
1846 0 0 if (ref $val eq 'HASH') { }
0 0 elsif (ref $val eq 'ARRAY') { }
1851 0 0 if @$val
1853 0 0 if ref $_ eq "HASH" or ref $_ eq "SCALAR"
1858 0 0 if ($isSubdir) { }
1860 0 0 unless $tagInfo
1865 0 0 if ref $val eq "ARRAY"
1867 0 0 if (not $tagInfo and defined $val and $unknown)
1876 0 0 unless defined $val
1878 704 419 unless ($tagInfo)
1880 704 0 unless $unknown
1885 0 419 if ($isSubDoc)
1890 332 87 if ($tagInfo->{'SubDirectory'}) { }
1893 37 295 if (ref $val eq 'ARRAY') { }
1895 0 37 if ($tagInfo->{'ConvertToDict'} and @$val == 2 and not ref $val->[0]) { }
1908 332 332 unless my $subDict = shift @subDicts
1911 244 88 if (ref $subDict eq "SCALAR")
1913 47 197 if $fetched{$$subDict}
1914 28 169 if ($tagInfo->{'IgnoreDuplicates'})
1916 0 28 if ($et->{$flag}) { }
1917 0 0 if $et->WarnOnce("Ignored duplicate $tag dictionary", 2)
1925 5 192 unless (defined $obj)
1926 0 5 unless (defined $lastOffset)
1933 0 280 if (ref $subDict eq 'ARRAY') { }
1935 0 0 if @$subDict < 2
1945 0 280 unless ref $subDict eq "HASH"
1949 0 280 unless $Image::ExifTool::PDF::lastFetched
1951 280 0 if (not $verbose) { }
0 0 elsif ($next) { }
1977 0 87 if (ref $val eq 'SCALAR') { }
1981 0 0 if (defined $val)
1984 0 0 $Image::ExifTool::PDF::lastFetched ? :
0 0 if $cryptString
1990 12 75 if (ref $val) { }
75 0 elsif (defined $val) { }
1991 12 0 if (ref $val eq "ARRAY")
1992 12 0 if $tagInfo->{'List'}
2002 10 65 if $format eq "date"
2003 0 75 if (not $tagInfo->{'Binary'} and $val =~ /[\x18-\x1f\x80-\xff]/)
2006 0 0 $val =~ s/^\xfe\xff// ? :
2008 12 63 if ($tagInfo->{'List'} and not $et->{'OPTIONS'}{'NoPDFList'}) { }
2010 12 0 $val =~ /,/ ? :
2020 0 419 if ($isSubDoc)
2023 0 0 if $oldNumTags == $et->{'NUM_FOUND'}
2030 0 350 if (%join)
2034 0 0 unless defined $list->[1] and $list->[1] =~ /^%.*?([\x0d\x0a]*)/
2048 0 0 if $oldNumTags == $et->{'NUM_FOUND'}
2056 307 43 unless $dict->{'_stream'}
2059 21 22 if $dict->{'Subtype'}
2060 0 43 unless $tagTablePtr->{$tag}
2061 0 43 unless my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag)
2062 0 43 unless ($tagInfo->{'SubDirectory'})
2068 0 0 if ref $filter eq "ARRAY"
2070 0 0 if ($filter eq "/DCTDecode" or $filter eq "/JPXDecode")
2071 0 0 unless &DecodeStream($et, $dict)
2077 0 0 unless ($result)
2078 0 0 defined $result ? :
2083 0 43 unless &DecodeStream($et, $dict)
2084 0 43 if ($verbose > 2)
2097 0 43 unless ($et->ProcessDirectory(\%dirInfo, $subTablePtr))
2118 0 37 unless $raf->Read($buff, 1024) >= 8
2119 0 37 unless $buff =~ /^(\s*)%PDF-(\d+\.\d+)/
2120 0 37 if $et->{'PDFBase'} = length $1
2123 0 37 if $pdfVer >= 2
2132 18 19 unless ($capture)
2134 18 0 if ($buff =~ /<
2137 0 0 if (ref $dict eq "HASH" and $dict->{'Linearized'} and $dict->{'L'})
2138 0 0 if (not $et->{'VALUE'}{'FileSize'}) { }
0 0 elsif ($dict->{'L'} == $et->{'VALUE'}{'FileSize'} - $et->{'PDFBase'}) { }
2145 18 0 if $lin
2151 0 37 unless $raf->Seek(0, 2)
2154 37 0 if $len > 1024
2155 0 37 unless $raf->Seek(-$len, 2)
2156 0 37 unless $raf->Read($buff, $len) == $len
2159 0 37 unless $buff =~ /^.*startxref(\s+)(\d+)(\s+)(%[^\x0d\x0a]*\s+)*%%EOF/s
2164 37 0 $ws =~ /(\x0d\x0a|\x0d|\x0a)/ ? :
2168 19 18 if ($capture)
2178 0 70 if $loaded{$offset}
2179 0 70 unless ($raf->Seek($offset + $et->{'PDFBase'}, 0))
2180 0 0 unless %loaded
2187 0 70 unless ($raf->ReadLine($buff))
2188 0 0 unless %loaded
2192 70 0 if $buff =~ /\S/
2195 70 0 if ($buff =~ s/^\s*xref\s+//s) { }
0 0 elsif ($buff =~ s/^\s*(\d+)\s+(\d+)\s+obj//s) { }
2200 70 107 if $buff =~ s/^\s*trailer([\s<[(])/$1/s
2201 0 107 unless $buff =~ s/^\s*(\d+)\s+(\d+)\s+//s
2203 0 107 unless $raf->Seek(-length($buff), 1)
2206 0 622 unless $raf->Read($buff, 20) == 20
2207 0 622 unless $buff =~ /^\s*(\d{10}) (\d{5}) (f|n)/s
2209 282 340 if $num > $xrefSize
2212 0 622 if $xref{'dicts'}
2215 526 96 unless (defined $xref{$num})
2218 52 474 if ($3 eq "f")
2220 25 27 if $mainFree
2236 0 0 unless %loaded
2241 0 70 unless (ref $mainDict eq "HASH")
2242 0 0 unless %loaded
2247 37 33 if $mainDict->{'Size'} and $mainDict->{'Size'} > $mainDictSize
2248 0 70 if ($loadXRefStream)
2256 0 0 if ($mainDict->{'Type'} eq '/XRef' and $mainDict->{'W'} and @{$mainDict->{'W'};} > 2 and $mainDict->{'Size'} and &DecodeStream($et, $mainDict)) { }
2261 0 0 unless $mainDict->{'Index'}
2268 0 0 unless $xref{'dicts'}
2271 0 0 unless %loaded
2277 0 70 if $mainDict->{'XRefStm'}
2278 0 70 if $mainDict->{'Encrypt'}
2279 0 70 if $encrypt and $encrypt eq "null"
2280 29 41 if ($mainDict->{'ID'} and ref $mainDict->{'ID'} eq "ARRAY")
2285 33 37 if $mainDict->{'Prev'}
2287 0 37 if ($xrefSize > $mainDictSize)
2289 0 0 $capture ? :
2294 0 37 if ($encrypt)
2295 0 0 if (ref $encrypt eq "SCALAR")
2300 0 0 if ($err)
2302 0 0 if $capture
2314 0 70 if ($verbose)
2322 0 37 if ($encrypt)
2324 0 0 if ($err)
2326 0 0 if $capture
2359 0 37 if ($result < 0)
2360 0 0 if $pdfWarning{$result}