Branch Coverage

blib/lib/Image/ExifTool/PDF.pm
Criterion Covered Total %
branch 290 742 39.0


line true false branch
642 0 10 if (length $date < length $default)
645 0 10 unless $date =~ /^(\d{4})(\d{2})(\d{2})(\d{2})(\d{2})(\d{2})(.*)/
647 10 0 if ($7)
649 0 10 if ($tz =~ /^\s*Z/i) { }
10 0 elsif ($tz =~ /^\s*([-+])\s*(\d+)[': ]+(\d*)/) { }
668 0 238 unless $xref
669 231 7 if exists $xref->{$ref}
671 0 7 unless $ref =~ /^(\d+)/
674 6 1 if defined $xref->{$objNum}
678 1 0 unless $xref->{'dicts'}
682 0 0 if $objNum >= $dict->{'Size'}
684 0 0 if $objNum < $index->[0]
694 0 0 if $objNum < $start
695 0 0 if ($objNum < $start + $count)
697 0 0 if $offset + $size > length $dict->{'_stream'}
706 0 0 $j ? :
0 0 unless $w->[$j]
715 0 0 if ($t[0] == 1) { }
0 0 elsif ($t[0] == 2) { }
0 0 elsif ($t[0] == 0) { }
733 0 0 if $ref eq $ref2
751 0 41 if $offset and $offset =~ /^I/
765 0 217 unless $raf->Seek($offset + $et->{'PDFBase'}, 0)
769 0 217 unless $raf->ReadLine($data)
770 217 0 if $data =~ s/^$obj//
771 0 0 if $data =~ /^\s+$/
778 0 0 unless ($data =~ s/$pat//)
787 217 217 if $data =~ /\S/ and not $data =~ /^\s*%/
788 0 217 unless $raf->ReadLine($data)
806 5 192 unless ($offset)
807 0 5 unless defined $offset
811 0 192 if ($offset =~ s/^I(\d+) //)
816 0 0 unless ($obj)
818 0 0 if defined $obj
823 0 0 unless defined $obj and ref $obj eq "HASH"
824 0 0 unless $obj->{'First'} and $obj->{'N'}
825 0 0 unless &DecodeStream($et, $obj)
830 0 0 unless @table == $num
841 0 0 unless ($index < $obj->{'N'} and $table->[$i] == $objNum)
852 0 0 if $cryptStream
857 0 192 unless defined $data
870 27 196 if (ref $str eq "ARRAY")
878 0 196 unless length $str
880 58 138 if ($delim eq '(') { }
41 97 elsif ($delim eq '<') { }
0 97 elsif ($delim eq '/') { }
881 58 0 if $str =~ /^.*?\((.*)\)/s
887 0 0 if ($c =~ /[0-7]/) { }
0 0 elsif ($c eq "\r") { }
0 0 elsif ($c eq "\n") { }
889 0 0 if $str =~ /\G([0-7]{1,2})/g
895 0 0 if $str =~ /\G(\x0a)/g
907 0 58 if $cryptString
911 0 41 if length $str & 1
913 12 29 if $cryptString
917 0 0 if $pdfVer >= "1.2"
943 754 70 if ($$dataPt =~ /^\s*(<{1,2}|\[|\()/s) { }
0 70 elsif ($$dataPt =~ s<^\s*(\S[^[(/<>\s]*)\s*>[]s) { }
947 0 754 unless defined $objData
955 0 0 if ($objData =~ /^\d+$/ and $$dataPt =~ s/^(\d+)\s+R//s)
961 0 70 unless $raf and $raf->ReadLine($data)
967 160 594 if ($delim eq '(' or $delim eq '<') { }
167 427 elsif ($delim eq '[') { }
973 0 167 unless $objData =~ /^.*?\[(.*)\]/s
977 167 427 unless $data =~ m<\s*(\S[^[(/<>\s]*)>gs
979 78 349 if ($val =~ /^(<{1,2}|\[|\()/) { }
245 104 elsif ($val =~ /^\d/) { }
984 0 78 unless defined $val
989 37 208 if ($data =~ /\G\s+(\d+)\s+R/g) { }
1009 396 833 if ($val =~ /^(<{1,2}|\[|\()/) { }
618 215 elsif ($val =~ /^\d/) { }
1013 0 396 unless defined $val
1018 416 202 if ($objData =~ /\G\s+(\d+)\s+R/gs) { }
1024 0 1229 if ($dict->{$tag}) { }
1033 0 427 unless @tags
1035 165 262 unless $raf
1040 219 43 unless my $length = $dict->{'Length'}
1041 25 18 if (ref $length)
1046 0 25 unless my $offset = &LocateObject($xref, $length)
1047 0 25 unless $offset
1049 0 25 unless defined $data
1050 0 25 unless $data =~ /^\s*(\d+)/
1057 43 43 if ($$dataPt =~ /(\S+)/)
1058 0 43 unless $1 eq "stream"
1060 43 0 if $raf->ReadLine($data)
1064 28 15 if ($more > 0) { }
15 0 elsif ($more < 0) { }
1065 0 28 unless ($raf->Read($data, $more) == $more)
1081 0 43 unless $raf->ReadLine($data)
1105 1148 4596 unless ($$dataPt =~ /(\\*)(\(|\)|<{1,2}|>{1,2}|\[|\]|%)/g)
1108 0 1148 unless $raf and $raf->ReadLine($buff)
1114 434 4162 if ($delim[0] eq ')') { }
0 4162 elsif ($2 eq '%') { }
1116 0 434 if length $1 & 1
1118 0 434 unless $2 eq "(" or $2 eq ")"
1129 2298 2298 if ($closingDelim{$2})
1134 0 2298 unless ($2 eq $delim[0])
1137 0 0 unless $2 eq ">>" and $delim[0] eq ">"
1141 1070 1228 if $delim[0]
1157 0 0 if length $$dataPt < 4
1167 0 0 if ($shift < 0)
1168 0 0 if $pos >= @dat
1176 0 0 if (defined $val) { }
0 0 elsif ($code == @lzw) { }
0 0 elsif ($code == 256) { }
0 0 elsif ($code == 257) { }
1178 0 0 if defined $lastVal
1180 0 0 unless defined $lastVal
1200 0 0 if @lzw >= $mask and $bits < 12
1216 0 43 unless $dict->{'_stream'}
1220 0 43 if (ref $dict->{'Filter'} eq 'ARRAY') { }
0 43 elsif (defined $dict->{'Filter'}) { }
1227 0 0 if $supportedFilter{$filter}
1234 43 0 unless (defined $dict->{'_decrypted'} or $filters[0] and $filters[0] eq "/Crypt")
1237 43 0 unless $dict->{'Filter'}
1238 0 0 if defined $dict->{'_filtered'}
1242 0 0 if (ref $dict->{'DecodeParms'} eq 'ARRAY') { }
1251 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') { }
1254 0 0 if (ref $decodeParms eq "HASH")
1256 0 0 if ($pre and $pre ne 1 and $pre ne 12)
1261 0 0 if (eval { do { require Compress::Zlib } }) { }
1264 0 0 if $inflate
1265 0 0 if ($inflate and $stat == Compress::Zlib::Z_STREAM_END()) { }
1275 0 0 unless $pre and $pre eq 12
1279 0 0 unless ($cols)
1288 0 0 unless (($_ = shift @bytes) == 2)
1303 0 0 if defined $dict->{'_decrypted'}
1305 0 0 unless ref $decodeParms eq "HASH"
1307 0 0 unless defined $name or $name eq "Identity"
1308 0 0 if ($name ne "StdCF")
1312 0 0 unless ($cryptInfo)
1324 0 0 $cryptStream ? :
1329 0 0 if (ref $decodeParms eq "HASH")
1330 0 0 if ($decodeParms->{'Predictor'}) { }
0 0 elsif ($decodeParms->{'EarlyChange'}) { }
1338 0 0 unless (&DecodeLZW(\$dict->{'_stream'}))
1354 0 0 if ($_ ge '!' and $_ le 'u') { }
0 0 elsif ($_ eq '~') { }
0 0 elsif ($_ eq 'z') { }
1356 0 0 unless ++$n == 5
1358 0 0 if $n == 1
1361 0 0 if $n
1364 0 0 if /^\s$/
1372 0 0 if $_ eq "~"
1375 0 0 if $err
1409 22 0 unless ref $key eq "HASH"
1435 0 0 if length $dat
1440 0 0 if ($pos < length $dat) { }
1458 6 0 if $rev == 5
1479 0 0 if length $password
1481 0 0 if length $vector
1482 0 0 if ($j == 0)
1513 0 4 unless ($encrypt and ref $encrypt eq "HASH")
1517 0 4 unless ($filt and $filt =~ s[^/][])
1524 4 0 if $filt eq "Standard"
1525 0 4 if $encrypt->{'SubFilter'} and $encrypt->{'SubFilter'} =~ m[^/(.*)]
1526 4 0 if $filt eq "Standard"
1529 0 4 if ($filt ne 'Standard') { }
0 4 elsif (not defined $encrypt->{'R'}) { }
1534 0 4 unless ($encrypt->{'O'} and $encrypt->{'P'} and $encrypt->{'U'})
1537 0 4 if ("$ver.$rev" >= "5.6")
1545 1 3 if ($ver == 1 or $ver == 2) { }
3 0 elsif ($ver == 4 or $ver == 5) { }
1550 3 3 $_ eq 'StrF' ? :
1552 0 6 if $$flagPt and $$flagPt eq "/Identity"
1553 0 6 if $$flagPt and $$flagPt ne "/StdCF"
1555 3 0 if ($cryptString or $cryptStream)
1557 0 3 unless ref $encrypt->{'CF'} eq "HASH" and ref $encrypt->{'CF'}{'StdCF'} eq "HASH" and $encrypt->{'CF'}{'StdCF'}{'CFM'}
1559 0 3 unless ($cryptMeth =~ m[^/(V2|AESV2|AESV3)$])
1563 3 0 if $cryptMeth =~ m[^/(AESV2|AESV3)$]
1565 2 1 if ($ver == 5)
1568 0 4 unless $encrypt->{$_}
1570 0 4 unless length $parm{$_} == 32
1577 0 4 unless $id
1580 2 2 if ($ver < 5) { }
1581 0 2 unless (eval { do { require Digest::MD5 } })
1585 0 2 unless (eval { do { require Digest::SHA } })
1598 2 1 if ($ver < 4 or not $encrypt->{'EncryptMetadata'} or not $encrypt->{'EncryptMetadata'} =~ /false/i)
1605 4 1 if ($try == 0) { }
1 0 elsif ($try == 1) { }
1609 0 1 unless defined $password
1611 0 1 if ($] >= "5.006" and $et->{'OPTIONS'}{'EncodeHangs'} || eval { do { require Encode; &Encode::is_utf8($password) } } || $@)
1616 0 0 $] < 5.01 ? :
0 0 $et->{'OPTIONS'}{'EncodeHangs'} || $@ ? :
1622 2 3 if ($ver < 5) { }
1623 0 2 if (length $password) { }
1627 0 0 if (length $password > 32) { }
0 0 elsif (length $password < 32) { }
1637 1 1 if ($rev == 3 or $rev == 4)
1639 1 0 unless $encrypt->{'_meta'}
1643 1 1 if ($ver == 1) { }
1647 0 1 unless $len >= 40
1654 1 1 if ($rev >= 3) { }
1667 2 0 if $dat eq $u
1669 0 3 if length $o < 48 or length $u < 48
1670 1 2 if (length $password)
1675 0 1 if length $password > 127
1679 2 1 if ($sha eq substr($o, 0, 32))
1684 0 2 if $err
1690 0 1 if ($sha eq substr($u, 0, 32))
1694 0 0 if $err
1713 25 4 unless $cryptInfo
1717 0 4 unless defined $keyExt
1720 2 2 unless ($cryptInfo->{'_aesv3'})
1721 2 0 unless ($keyExt eq "none")
1723 0 2 unless ($keyExt =~ /^(I\d+ )?(\d+) (\d+)/)
1733 1 1 if $cryptInfo->{'_aesv2'}
1736 1 1 if $len < 16
1739 3 1 if ($cryptInfo->{'_aesv2'} or $cryptInfo->{'_aesv3'}) { }
1742 0 3 if $err
1753 52 0 unless $cryptStream
1758 0 0 if ($cryptInfo and $type ne '/XRef' and $cryptInfo->{'_meta'} || $type ne '/Metadata') { }
1763 0 0 $dict->{'_decrypted'} ? :
1792 0 0 $dict->{'XFA'} ? :
1793 0 0 unless $et->Options("Verbose")
1805 0 0 unless $et->Options("Verbose") or $et->{'AFRelationship'} eq "/C2PA_Manifest"
1818 0 0 if ref $_ eq "SCALAR"
1819 0 0 if ref $_ eq "ARRAY"
1820 0 0 unless defined $_
1842 0 350 if ($nesting > 50)
1847 66 0 if ($et->{'PDF_CAPTURE'} and $tagTablePtr->{'VARS'} and $tagTablePtr->{'VARS'}{'CAPTURE'})
1852 16 66 if $et->{'PDF_CAPTURE'}{$name}
1854 0 66 if $type and $type ne $name
1865 1123 350 if (@tags) { }
0 350 elsif (defined $next and not $next) { }
1875 434 689 if ($tagInfo) { }
0 689 elsif ($embedded and $tag =~ /^(.*?)(\d+)$/ and $tagTablePtr->{$1} and ref $val ne 'SCALAR' || !$fetched{$$val}) { }
1876 0 434 if $tagInfo->{'NoProcess'}
1882 0 0 if (ref $tagInfo eq 'HASH' and $tagInfo->{'JoinStreams'}) { }
1885 0 0 unless $join{$name}
1886 0 0 unless ref $obj eq "HASH" and $obj->{'_stream'}
1895 0 0 if ($validInfo and $et->{'PDFVersion'} >= 2 and not $tagInfo && $tagInfo->{'PDF2'})
1896 0 0 $tagInfo ? :
1899 0 1123 if ($verbose)
1901 0 0 if (ref $val eq 'SCALAR') { }
0 0 elsif (ref $val eq 'HASH') { }
0 0 elsif (ref $val eq 'ARRAY') { }
1903 0 0 if ($fetched{$$val}) { }
0 0 elsif ($tag eq 'Next' and not $next) { }
1912 0 0 unless (defined $val)
1914 0 0 if (defined $lastOffset) { }
1932 0 0 if (ref $val eq 'HASH') { }
0 0 elsif (ref $val eq 'ARRAY') { }
1937 0 0 if @$val
1939 0 0 if ref $_ eq "HASH" or ref $_ eq "SCALAR"
1944 0 0 if ($isSubdir) { }
1946 0 0 unless $tagInfo
1951 0 0 if ref $val eq "ARRAY"
1953 0 0 if (not $tagInfo and defined $val and $unknown)
1962 0 0 unless defined $val
1964 689 434 unless ($tagInfo)
1966 689 0 unless $unknown
1971 0 434 if ($isSubDoc)
1976 332 102 if ($tagInfo->{'SubDirectory'}) { }
1979 37 295 if (ref $val eq 'ARRAY') { }
1981 0 37 if ($tagInfo->{'ConvertToDict'} and @$val == 2 and not ref $val->[0]) { }
1994 332 332 unless my $subDict = shift @subDicts
1997 244 88 if (ref $subDict eq "SCALAR")
1999 47 197 if $fetched{$$subDict}
2000 28 169 if ($tagInfo->{'IgnoreDuplicates'})
2002 0 28 if ($et->{$flag}) { }
2003 0 0 if $et->Warn("Ignored duplicate $tag dictionary", 2)
2011 5 192 unless (defined $obj)
2012 0 5 unless (defined $lastOffset)
2019 0 280 if (ref $subDict eq 'ARRAY') { }
2021 0 0 if @$subDict < 2
2031 0 280 unless ref $subDict eq "HASH"
2035 0 280 unless $Image::ExifTool::PDF::lastFetched
2037 280 0 if (not $verbose) { }
0 0 elsif ($next) { }
2064 0 102 if (ref $val eq 'SCALAR') { }
2068 0 0 if (defined $val)
2071 0 0 $Image::ExifTool::PDF::lastFetched ? :
0 0 if $cryptString
2077 27 75 if (ref $val) { }
75 0 elsif (defined $val) { }
2078 27 0 if (ref $val eq "ARRAY")
2079 27 0 if $tagInfo->{'List'}
2089 10 65 if $format eq "date"
2090 0 75 if (not $tagInfo->{'Binary'} and $val =~ /[\x18-\x1f\x80-\xff]/)
2093 0 0 $val =~ s/^\xfe\xff// ? :
2095 12 63 if ($tagInfo->{'List'} and not $et->{'OPTIONS'}{'NoPDFList'}) { }
2100 12 0 if ($comma or $semi) { }
2101 12 0 $comma > $semi ? :
2113 0 434 if ($isSubDoc)
2116 0 0 if $oldNumTags == $et->{'NUM_FOUND'}
2123 0 350 if (%join)
2127 0 0 unless defined $list->[1] and $list->[1] =~ /^%.*?([\x0d\x0a]*)/
2141 0 0 if $oldNumTags == $et->{'NUM_FOUND'}
2149 307 43 unless $dict->{'_stream'}
2152 21 22 if $dict->{'Subtype'}
2153 0 43 unless $tagTablePtr->{$tag}
2154 0 43 unless my $tagInfo = $et->GetTagInfo($tagTablePtr, $tag)
2156 0 43 unless ($subdir)
2162 0 0 if ref $filter eq "ARRAY"
2164 0 0 if ($filter eq "/DCTDecode" or $filter eq "/JPXDecode")
2165 0 0 unless &DecodeStream($et, $dict)
2171 0 0 unless ($result)
2172 0 0 defined $result ? :
2177 0 0 if ($cryptInfo and $cryptInfo->{'_aesv2'} || $cryptInfo->{'_aesv3'} && $dict->{'Length'} && $dict->{'Length'} > 10000 and not $dict->{'_decrypted'} and not $et->{'PDF_CAPTURE'})
2182 0 0 if ($type ne "/Metadata" or $dict->{'Length'} > 100000)
2183 0 0 if ($et->{'OPTIONS'}{'IgnoreMinorErrors'}) { }
2191 0 43 unless &DecodeStream($et, $dict)
2192 0 43 if ($verbose > 2)
2206 0 43 unless ($et->ProcessDirectory(\%dirInfo, $subTablePtr))
2227 0 37 unless $raf->Read($buff, 1024) >= 8
2228 0 37 unless $buff =~ /^(\s*)%PDF-(\d+\.\d+)/
2229 0 37 if $et->{'PDFBase'} = length $1
2240 18 19 unless ($capture)
2242 18 0 if ($buff =~ /<
2245 0 0 if (ref $dict eq "HASH" and $dict->{'Linearized'} and $dict->{'L'})
2246 0 0 if (not $et->{'VALUE'}{'FileSize'}) { }
0 0 elsif ($dict->{'L'} == $et->{'VALUE'}{'FileSize'} - $et->{'PDFBase'}) { }
2253 18 0 if $lin
2259 0 37 unless $raf->Seek(0, 2)
2262 37 0 if $len > 1024
2263 0 37 unless $raf->Seek(-$len, 2)
2264 0 37 unless $raf->Read($buff, $len) == $len
2267 0 37 unless $buff =~ /^.*startxref(\s+)(\d+)(\s+)((%[^\x0d\x0a]*\s+)*)%%EOF/s
2269 0 37 if ($4)
2272 0 0 unless /^(%+\s*)
2282 37 0 $ws =~ /(\x0d\x0a|\x0d|\x0a)/ ? :
2286 19 18 if ($capture)
2296 0 70 if $loaded{$offset}
2297 0 70 unless ($raf->Seek($offset + $et->{'PDFBase'}, 0))
2298 0 0 unless %loaded
2305 0 70 unless ($raf->ReadLine($buff))
2306 0 0 unless %loaded
2310 70 0 if $buff =~ /\S/
2313 70 0 if ($buff =~ s/^\s*xref\s+//s) { }
0 0 elsif ($buff =~ s/^\s*(\d+)\s+(\d+)\s+obj//s) { }
2318 70 107 if $buff =~ s/^\s*trailer([\s<[(])/$1/s
2319 0 107 unless $buff =~ s/^\s*(\d+)\s+(\d+)\s+//s
2321 0 107 unless $raf->Seek(-length($buff), 1)
2324 0 622 unless $raf->Read($buff, 20) == 20
2325 0 622 unless $buff =~ /^\s*(\d{10}) (\d{5}) (f|n)/s
2327 282 340 if $num > $xrefSize
2330 0 622 if $xref{'dicts'}
2333 526 96 unless (defined $xref{$num})
2336 52 474 if ($3 eq "f")
2338 25 27 if $mainFree
2354 0 0 unless %loaded
2359 0 70 unless (ref $mainDict eq "HASH")
2360 0 0 unless %loaded
2365 37 33 if $mainDict->{'Size'} and $mainDict->{'Size'} > $mainDictSize
2366 0 70 if ($loadXRefStream)
2374 0 0 if ($mainDict->{'Type'} eq '/XRef' and $mainDict->{'W'} and @{$mainDict->{'W'};} > 2 and $mainDict->{'Size'} and &DecodeStream($et, $mainDict)) { }
2379 0 0 unless $mainDict->{'Index'}
2386 0 0 unless $xref{'dicts'}
2389 0 0 unless %loaded
2395 0 70 if $mainDict->{'XRefStm'}
2396 0 70 if $mainDict->{'Encrypt'}
2397 0 70 if $encrypt and $encrypt eq "null"
2398 29 41 if ($mainDict->{'ID'} and ref $mainDict->{'ID'} eq "ARRAY")
2403 33 37 if $mainDict->{'Prev'}
2405 0 37 if ($xrefSize > $mainDictSize)
2407 0 0 $capture ? :
2412 0 37 if ($encrypt)
2413 0 0 if (ref $encrypt eq "SCALAR")
2418 0 0 if ($err)
2420 0 0 if $capture
2432 0 70 if ($verbose)
2440 0 37 if ($encrypt)
2442 0 0 if ($err)
2444 0 0 if $capture
2477 0 37 if ($result < 0)
2478 0 0 if $pdfWarning{$result}