Branch Coverage

blib/lib/Image/ExifTool/WriteXMP.pl
Criterion Covered Total %
branch 454 646 70.2


line true false branch
59 1 121 if (defined $nv) { }
61 1 0 $tk ? :
66 122 0 $tk ? :
78 0 4 unless ($$xmpPt =~ /^\0*<\0*\?\0*x\0*p\0*a\0*c\0*k\0*e\0*t/)
79 0 0 unless $$xmpPt =~ /^
83 1 3 unless $mode
86 0 4 unless $end =~ s/(e\0*n\0*d\0*=\0*['"]\0*)([rw])(\0*['"]\0*\?\0*>)/$1$mode$3/
87 0 4 if $2 ne $mode
99 0 0 if ($et->{'XmpValidate'} and @$propList > 2)
100 0 0 if ($propList->[0] =~ /^x:x[ma]pmeta$/ and $propList->[1] eq 'rdf:RDF' and $propList->[2] =~ /rdf:Description( |$)/) { }
0 0 elsif ($propList->[0] ne 'rdf:RDF' or not $propList->[1] =~ /rdf:Description( |$)/) { }
104 0 0 if (@$propList > 3)
105 0 0 if ($propList->[-1] =~ /^rdf:(Bag|Seq|Alt)$/) { }
108 0 0 if ($propList->[-2] eq "rdf:Alt" and $attr)
110 0 0 if ($lang and @$propList >= 5)
113 0 0 unless $valLang->{$langPath}
114 0 0 if ($valLang->{$langPath}{$lang}) { }
123 0 0 if (defined $xmpValidate->{$path}) { }
146 99 28 if ($val =~ /(\d{4}):(\d{2}):(\d{2}) (\d{2}:\d{2}(?::\d{2}(?:\.\d*)?)?)(.*)/) { }
28 0 elsif ($val =~ /^\s*\d{4}(:\d{2}){0,2}\s*$/) { }
0 0 elsif ($val =~ /^\s*(\d{2}:\d{2}(?::\d{2}(?:\.\d*)?)?)(.*)\s*$/) { }
159 21 106 if ($tz)
160 0 21 unless $tz =~ /^(Z|[+-]\d{2}:\d{2})$/
175 95 2433 if ($tagInfo->{'Struct'})
178 73 22 unless (ref $$valPtr)
181 61 12 unless (ref $$valPtr)
182 0 61 if $$valPtr eq ""
186 1 33 if (ref $$valPtr eq 'ARRAY') { }
187 1 0 unless $tagInfo->{'List'}
191 0 0 unless (ref $item eq "HASH")
193 0 0 if $w
194 0 0 if ref $item eq "HASH"
199 0 0 if $err
204 0 33 if $warn
209 217 1118 if (not $format or $format eq "string" or $format eq "lang-alt")
211 4 1311 if ($et->{'OPTIONS'}{'Charset'} ne 'UTF8') { }
212 4 0 if ($$valPtr =~ /[\x80-\xff]/)
220 0 1311 if (&FixUTF8($valPtr) and not $et->{'WarnBadUTF8'})
227 366 752 if ($format eq 'rational' or $format eq 'real') { }
591 161 elsif ($format eq 'integer') { }
92 69 elsif ($format eq 'date') { }
68 1 elsif ($format eq 'boolean') { }
1 0 elsif ($format eq '1') { }
229 8 9 unless (&Image::ExifTool::IsFloat($$valPtr) or $format eq "rational" and $$valPtr eq 'inf' || $$valPtr eq 'undef' || &Image::ExifTool::IsRational($$valPtr))
236 269 89 if ($format eq "rational")
241 557 34 if (&Image::ExifTool::IsInt($$valPtr)) { }
0 34 elsif (&Image::ExifTool::IsHex($$valPtr)) { }
250 0 92 unless $newDate
254 43 25 if (not $$valPtr or $$valPtr =~ /false/i or $$valPtr =~ /^no$/i) { }
25 0 elsif ($$valPtr ne 'true' or not $convType or $convType eq 'PrintConv') { }
255 0 0 if (not $$valPtr or $$valPtr ne "false" or not $convType or $convType eq "PrintConv")
263 0 1 unless &ValidateXMP($valPtr)
277 1634 7092 unless $tagInfo->{'PropertyPath'}
294 0 4021 if ref $tagInfo ne "HASH"
296 2327 1694 if ($structPtr) { }
299 2275 52 if ($flatInfo) { }
0 52 elsif (@$propList > 50) { }
300 0 2275 if $flatInfo->{'PropertyPath'}
309 1 2326 if $structPtr->{'TYPE'}
312 0 1694 if $tagInfo->{'PropertyPath'}
315 3 1691 if $srcInfo
316 3 1691 if $tagInfo->{'PropertyPath'}
318 60 1631 if ($tagInfo->{'RootTagInfo'})
320 60 0 if $tagInfo->{'PropertyPath'}
326 0 3958 unless $ns
328 2327 1631 if $propList
331 102 3856 if ($tagInfo->{'Writable'} and $tagInfo->{'Writable'} eq 'lang-alt') { }
334 0 102 if $tagInfo->{'LangCode'}
336 3 99 if ($tagInfo->{'List'} and $tagInfo->{'List'} ne 1)
343 418 3540 if $listType and $listType ne 1
346 231 3727 if ($strTable and not $parentID && ($tagTablePtr->{$parentID} && $tagTablePtr->{$parentID}{'NoSubStruct'} || length $parentID > 500))
353 18 213 if ref $strTable->{'NAMESPACE'}
357 499 2327 if $Image::ExifTool::XMP::specialStruct{$tag} or $strTable->{$tag}{'LangCode'}
358 1418 909 $parentID ? :
364 2327 1631 if ($structPtr)
367 1 2326 if $isType
381 0 1149 unless defined $val and @$propList > 2
382 1148 1 if ($propList->[0] =~ /^x:x[ma]pmeta$/ and $propList->[1] eq 'rdf:RDF' and $propList->[2] =~ /$rdfDesc( |$)/) { }
1 0 elsif ($propList->[0] eq 'rdf:RDF' and $propList->[1] =~ /$rdfDesc( |$)/) { }
387 8 1140 unless @$propList > 3
389 0 1140 if ($propList->[-1] =~ /^rdf:(Bag|Seq|Alt)$/)
396 0 1140 if (defined $capture->{$path}) { }
432 0 30 unless defined $pre
435 12 18 unless ($prop eq $rdfDesc)
436 8 4 if ($post) { }
443 26 4 if (defined $post and length $post or defined $val and length $val)
457 2 2 unless $isWriting
470 8 8 unless $pre =~ m[/$rdfDesc/]
474 19 19 if ($isWriting) { }
483 4 4 if (%unused)
484 0 4 if $et->Options("Verbose")
488 4 4 if ($isWriting) { }
511 10124 13718 if not defined $ns or $nsUsed->{$ns}
513 0 13718 unless ($uri)
519 73697 0 unless $nsUsed->{$ns2} eq $uri
540 0 5 unless @props
542 3 2 if $doneID{$tagID}
545 0 2 unless ref $tagInfo eq "HASH"
546 1 1 if ($tagInfo->{'Struct'})
548 1 0 if ($type)
550 0 1 unless $pat
553 0 1 unless $path =~ /^($pat)/
555 1 0 if $basePath
556 1 0 unless $capture->{$p}
559 1 1 unless $tagInfo->{'StructType'}
572 0 0 if ($dataPt and $$dataPt)
583 0 0 if ($xmp)
606 34 8 if $n > $chunkSize
614 8 0 if $pad < 3
615 0 8 if $_[1]
630 20 7762 if ($a =~ /rdf:type$/) { }
14 7748 elsif ($b =~ /rdf:type$/) { }
631 18 2 unless $b =~ /rdf:type$/
649 35 0 if length $$dataPt < $maxLen
656 0 0 if ($et->{'OPTIONS'}{'Compact'}{'Shorthand'}) { }
674 0 0 if $i xor $start >= $extStart
675 0 0 length($newData) + $descSize{$start} > $maxLen ? :
681 0 0 if (eval { do { require Digest::MD5 } })
702 1 1058 if ($$resFlag[@$curPropList]) { }
6 1052 elsif (defined $$resFlag[@$curPropList]) { }
704 1 0 if (length $short->[-1]) { }
705 0 1 if (length $long->[-1]) { }
717 0 0 length $long->[-1] ? :
719 0 1 if length $long->[-1]
725 3 3 if (length $long->[-1]) { }
734 300 752 unless (@$curPropList)
757 6018 123 unless $et
767 26 97 if not defined $dirLen and $dataPt
785 0 123 $compact{'NoIndent'} ? :
0 123 $compact{'NoNewline'} ? :
789 1 122 if (defined $et->{'NEW_VALUE'}{$tagInfo})
793 72 51 if ($xmpFile or $dirLen) { }
0 51 elsif (defined $about) { }
798 16 56 unless ($success and not $et->{'XMP_ERROR'})
801 16 0 if ($xmpFile) { }
804 0 16 if ($success or not $raf->Seek(0, 2) or $raf->Tell)
806 0 0 unless $et->{'XMP_ERROR'}
807 0 0 if ($et->Error($err, $success))
813 0 0 if $success and $success eq 1
814 0 0 if ($et->Warn($err, $success))
820 1 71 if (defined $about) { }
821 0 1 if ($verbose > 1)
823 0 0 if defined $wasAbout
834 0 72 if $xmpFile and $et->GetNewValue("ForceWrite")
836 0 72 if $et->{'FORCE_WRITE'}{'XMP'}
848 35 88 if ($xmpFile)
850 0 35 if ($tagInfo and $et->{'NEW_VALUE'}{$tagInfo})
853 0 0 if (defined $newVal and length $newVal)
856 0 0 unless &Write($dirInfo->{'OutFile'}, $newVal)
865 12 2 if (%{$et->{'DEL_GROUP'};} and grep(/^XMP-.+$/, keys %{$$et{'DEL_GROUP'};}) || grep(m[^http://ns.exiftool.(?:ca|org)/], values %nsUsed))
875 0 141 if $Image::ExifTool::XMP::stdXlatNS{$ns}
878 78 63 if ($nsUsed{$ns} and @g = $nsUsed{$ns} =~ m[^http://ns.exiftool.(?:ca|org)/(.*?)/(.*?)/]) { }
879 20 58 if ($g[1] =~ /^\d/) { }
883 13 7 unless $del->{$ucg} or $del->{'XML-*'} and not $$del{"-$ucg"}
886 18 18 unless $del->{$grp} or $$del{$g[0]} and not $$del{"-$grp"}
891 19 27 unless $del->{$ucg} or $del->{'XMP-*'} and not $$del{"-$ucg"}
900 1 122 if ($capture{$hasExtTag})
905 1 122 $et->{'XMP_NO_XMPMETA'} ? :
915 10697 4285 unless $et->GetGroup($tagInfo, 0) eq "XMP"
916 0 4285 if $tagInfo->{'Name'} eq "XMP"
917 0 4285 if $writeGroup and $writeGroup ne $et->{'NEW_VALUE'}{$tagInfo}{'WriteGroup'}
918 196 4089 if ($tagInfo->{'Struct'}) { }
928 0 4285 unless ($path)
933 2 4283 if ($path eq "rdf:about" or $path eq "x:xmptk")
949 2173 1980 if ($isStruct or defined $tagInfo->{'Flat'})
956 4286 5750 if ref $info eq "HASH" and $info->{'Struct'} and !@fixInfo || $fixInfo[0] ne $info
959 0 2173 unless @fixInfo
962 3957 196 unless @fixInfo and $isStruct
974 1967 2461 if ($regex =~ s[\\/rdf\\:(Bag|Seq|Alt)\\/][/rdf:(Bag|Seq|Alt)/]g) { }
1983 478 elsif (not @fixInfo) { }
976 1954 13 if ($regex =~ s[/rdf:\(Bag\|Seq\|Alt\)\/rdf\\:li\\ \\d\+$][])
977 349 1605 unless @fixInfo
984 2083 2345 if (@fixInfo)
989 4149 279 unless @matches
990 274 5 if ($matches[0] =~ /^$ok$/)
991 0 274 unless (@fixInfo)
1002 1 6 if $ok2 and $#matchProps > $#fixProps
1004 0 19 unless defined $matchProps[$i]
1005 15 4 if $matchProps[$i] =~ / \d+$/ or $matchProps[$i] eq $fixProps[$i]
1009 0 7 if $fixed{$fixed} or $capture{$fixed} and $match ne $fixed
1014 2 3 lc $fixed[0] eq lc $matches[0] ? :
1015 0 5 if ($err) { }
1022 2 5 if $fixed eq $match
1026 1 4 if $ok2 and not $match =~ /^$ok2$/
1029 4 1 unless @fixInfo
1030 3 2 if ($didFix)
1043 169 4114 if ($writable eq "lang-alt")
1045 8 161 if ($delLangPath and $delLangPath eq $path) { }
1047 2 6 if $delLangPaths{$newLang}
1054 2 167 if (%delAllLang)
1058 5 1 if grep /^$prefix/, @delPaths
1062 1 1 if $reSort
1066 196 4087 if ($isStruct) { }
132 3955 elsif ($cap) { }
1070 0 194 unless $deleted or $added or $et->IsOverwriting($nvHash)
1071 2 2 if $existed and $nvHash->{'CreateOnly'}
1073 2 130 if $nvHash->{'CreateOnly'}
1076 126 4 if ($overwrite) { }
1079 44 82 if ($path =~ / /) { }
1089 60 121 if ($writable eq 'lang-alt') { }
7 114 elsif ($overwrite < 0) { }
1093 38 22 unless ($langPathPat and $path =~ /^$langPathPat$/)
1099 24 36 unless (defined $addLang)
1101 21 3 $nvHash->{'IsCreating'} ? :
1103 13 47 if ($overwrite < 0)
1104 5 8 unless $oldLang eq $newLang
1108 5 3 unless $addLang
1112 13 37 if ($oldLang eq 'x-default' and not $tagInfo->{'LangCode'}) { }
31 12 elsif ($tagInfo->{'LangCode'} and not $delLang) { }
1117 27 4 unless lc $tagInfo->{'LangCode'} eq $oldLang
1121 3 4 if ($nvHash->{'Shift'})
1125 1 2 if ($fmt eq 'rational') { }
2 0 elsif ($fmt eq 'date') { }
1132 1 6 unless $et->IsOverwriting($nvHash, &UnescapeXML($val))
1134 0 143 if ($verbose > 1)
1137 0 0 if $tagInfo->{'LangCode'}
1138 0 0 if $attrs->{'xml:lang'}
1143 116 27 unless @delPaths
1144 23 120 if ($writable eq "lang-alt")
1149 137 6 if ($writable ne 'lang-alt' or $oldLang eq $newLang) { }
1152 3 3 unless $delLangPaths{$oldLang}
1156 19 124 if ($delLang)
1165 0 143 if ($path =~ m[^(.*)/] and $capture{"$1/rdf:type"})
1168 0 0 if @a == 1
1171 1 7 unless @delPaths or $tagInfo->{'List'} or $addLang
1172 118 7 if (@delPaths) { }
1176 0 0 unless $path =~ s/ \d(\d+)$/" " . length($1 + 1) . ($1 + 1);/e
1182 0 7 unless $tagInfo->{'List'} or $oldLang
1184 7 0 if ($writable eq "lang-alt" and %langsHere)
1186 0 9 unless $path =~ /^$_$/
1187 6 3 unless $langsHere{$_}{$newLang}
1188 0 3 unless $path =~ /(.* )\d(\d+)(.*? \d+)$/
1194 0 7 unless $path =~ /.* (\d+)/g
1201 2 2 if ($writable eq "lang-alt")
1202 1 1 if ($firstNewPath) { }
1209 4 0 if ($path =~ /$pat/g)
1212 1 3 if $2
1215 11 118 if (defined $added)
1221 2 9 if ($overwrite and $writable eq 'lang-alt' and !$tagInfo->{'LangCode'} || $tagInfo->{'LangCode'} eq 'x-default') { }
1231 1 0 unless $nextCap
1254 1635 2368 unless $deleted or defined $added or not $cap and $isCreating
1259 1767 876 unless my(@newValues) = $et->GetNewValue($nvHash)
1262 73 803 if ($writable eq "lang-alt")
1264 9 64 if defined $added
1270 30 965 if ($isStruct) { }
1272 30 0 if &AddNewStruct($et, $tagInfo, \%capture, $path, $newValue, $tagInfo->{'Struct'})
1276 3 962 if ($tagInfo->{'Resource'})
1278 3 0 unless ($newValue =~ m<[^a-z0-9\:/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~]>i)
1292 1 964 if ($verbose > 1)
1298 0 965 if ($tagInfo->{'StructType'})
1302 876 119 unless @newValues
1305 22 97 $writable eq 'lang-alt' ? :
1307 0 119 unless $path =~ /$pat/g
1310 22 97 $2 ? :
1312 50 69 if ($subIdx) { }
19 50 elsif (@delPaths) { }
1320 0 2 unless $path =~ s/ \d(\d+)$/" " . length($1 + 1) . ($1 + 1);/e
1330 318 558 if (defined $tagInfo->{'Flat'})
1333 420 0 unless $capture{$p}
1335 0 0 if $capture{$p}[0] =~ /\S/
1349 3 0 unless ($changed or $maxDataLen and $dataPt and defined $$dataPt and length $$dataPt > $maxDataLen)
1352 16 0 unless $xmpFile
1353 0 0 if $dataPt and defined $$dataPt
1362 1 106 if ($et->{'XMP_NO_XPACKET'}) { }
1364 0 1 if $et->{'XMP_NO_XPACKET'} == 2
1368 1 106 if $et->{'XMP_IS_XML'}
1376 33 74 if ($maxDataLen and @pathList)
1383 92 280 if ($1 eq $lastProp) { }
1387 14 266 if ($extendedRes{$lastProp} or $extendedRes{$lastNS} or $propSize > $newDescThresh) { }
1394 33 247 unless $path
1405 111 1828 unless (@pathList)
1406 107 4 unless @writeLast
1417 0 5515 unless $prop =~ /(.*):/
1418 3114 2401 if $1 eq "rdf"
1420 1381 1020 unless ($uri)
1422 0 1381 unless ($uri)
1424 0 0 if (length $1)
1426 0 0 if (not $xmpErr or $err ne $xmpErr)
1427 0 0 $xmpFile ? :
1436 370 2031 unless $nsCur{$1}
1439 306 1526 if ($newDesc) { }
1447 0 1725 $compact{'OneDesc'} ? :
1449 1020 2230 if $ns2 eq "rdf"
1450 2019 211 if $nsNew{$ns2}
1451 199 12 unless $opening
1453 0 12 unless my $uri = $nsUsed{$ns2} || $Image::ExifTool::XMP::nsURI{$ns2}
1456 199 1526 unless $opening
1461 0 2853 unless $closeTo < @propList
1462 232 2621 unless $propList[$closeTo] eq $curPropList[$closeTo]
1469 306 1526 if ($newDesc)
1470 0 306 if $newDesc == 2
1472 99 207 if $maxDataLen
1479 5 301 if (@ns and $nsCur{$ns[0]} =~ m[^http://ns.exiftool.(?:ca|org)/])
1486 6 300 if $compact{'Shorthand'}
1489 0 1832 if $debug
1498 0 756 $compact{'NoIndent'} ? :
1499 134 622 if ($prop ne $rdfDesc and !($propList[$n + 1] =~ /^rdf:/) || $propList[$n + 1] eq 'rdf:type' && $n + 1 == $#propList) { }
1503 3 131 if ($propList[$n + 1] =~ /:~dummy~$/)
1509 1 130 if ($compact{'Shorthand'}) { }
1523 1829 0 unless ($dummy or $val eq "" and $prop2 =~ /:~dummy~$/)
1525 0 1829 $compact{'NoIndent'} ? :
1527 19 1810 if (defined $resFlag[$#curPropList] and not %$attrs and not $val =~ /
1534 0 211 $attrVal =~ /'/ ? :
1537 1776 34 length $val ? :
1545 35 72 if ($maxDataLen)
1548 35 0 unless $extStart
1554 0 35 if length($long[-2]) + 101 * $numPadLines > $maxDataLen
1556 0 107 if $dirInfo->{'Compact'}
1561 106 1 unless $et->{'XMP_NO_XMPMETA'}
1570 106 1 unless ($et->{'XMP_NO_XPACKET'})
1574 0 106 if ($dirInfo->{'InPlace'} and not $dirInfo->{'InPlace'} == 2 && $len > $dirLen) { }
66 40 elsif (not $compact{'NoPadding'} || $xmpFile || $dirInfo->{'ReadOnly'}) { }
1576 0 0 if ($len > $dirLen)
1578 0 0 unless $compact{'Shorthand'}
1583 0 0 if ($num)
1587 0 0 if $len < $dirLen
1591 6 100 $dirInfo->{'ReadOnly'} ? :
1594 3 1 unless (%capture or $xmpFile or $dirInfo->{'InPlace'} or $dirInfo->{'NoDelete'})
1597 0 0 $xmpFile ? :
0 107 if $xmpErr
1599 0 0 if $debug > 1 and $long[-2]
1600 72 35 unless $xmpFile
1601 0 35 unless &Write($dirInfo->{'OutFile'}, $long[-2])