Branch Coverage

blib/lib/Image/ExifTool/WriteXMP.pl
Criterion Covered Total %
branch 461 656 70.2


line true false branch
59 1 128 if (defined $nv) { }
61 1 0 $tk ? :
66 129 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 101 28 if ($val =~ /(\d{4}):(\d{2}):(\d{2}) (\d{2}:\d{2}(?::\d{2}(?:\.\d*)?)?)(.*)/ or $val =~ /(\d{4})-(\d{2})-(\d{2})T(\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*$/) { }
161 22 107 if ($tz)
162 0 22 unless $tz =~ /^(Z|[+-]\d{2}:\d{2})$/
177 103 2510 if ($tagInfo->{'Struct'})
180 81 22 unless (ref $$valPtr)
183 69 12 unless (ref $$valPtr)
184 0 69 if $$valPtr eq ""
188 1 33 if (ref $$valPtr eq 'ARRAY') { }
189 1 0 unless $tagInfo->{'List'}
193 0 0 unless (ref $item eq "HASH")
195 0 0 if $w
196 0 0 if ref $item eq "HASH"
201 0 0 if $err
206 0 33 if $warn
211 217 1138 if (not $format or $format eq "string" or $format eq "lang-alt")
213 4 1368 if ($et->{'OPTIONS'}{'Charset'} ne 'UTF8') { }
214 4 0 if ($$valPtr =~ /[\x80-\xff]/)
222 0 1368 if (&FixUTF8($valPtr) and not $et->{'WarnBadUTF8'})
229 382 756 if ($format eq 'rational' or $format eq 'real') { }
592 164 elsif ($format eq 'integer') { }
94 70 elsif ($format eq 'date') { }
69 1 elsif ($format eq 'boolean') { }
1 0 elsif ($format eq '1') { }
231 8 9 unless (&Image::ExifTool::IsFloat($$valPtr) or $format eq "rational" and $$valPtr eq 'inf' || $$valPtr eq 'undef' || &Image::ExifTool::IsRational($$valPtr))
238 270 104 if ($format eq "rational")
243 558 34 if (&Image::ExifTool::IsInt($$valPtr)) { }
0 34 elsif (&Image::ExifTool::IsHex($$valPtr)) { }
252 0 94 unless $newDate
256 43 26 if (not $$valPtr or $$valPtr =~ /false/i or $$valPtr =~ /^no$/i) { }
26 0 elsif ($$valPtr ne 'true' or not $convType or $convType eq 'PrintConv') { }
257 0 0 if (not $$valPtr or $$valPtr ne "false" or not $convType or $convType eq "PrintConv")
265 0 1 unless &ValidateXMP($valPtr)
279 1729 7896 unless $tagInfo->{'PropertyPath'}
296 0 4426 if ref $tagInfo ne "HASH"
298 2635 1791 if ($structPtr) { }
301 2578 57 if ($flatInfo) { }
0 57 elsif (@$propList > 50) { }
302 0 2578 if $flatInfo->{'PropertyPath'}
311 1 2634 if $structPtr->{'TYPE'}
314 0 1791 if $tagInfo->{'PropertyPath'}
317 3 1788 if $srcInfo
318 3 1788 if $tagInfo->{'PropertyPath'}
320 62 1726 if ($tagInfo->{'RootTagInfo'})
322 62 0 if $tagInfo->{'PropertyPath'}
328 0 4361 unless $ns
330 2635 1726 if $propList
333 102 4259 if ($tagInfo->{'Writable'} and $tagInfo->{'Writable'} eq 'lang-alt') { }
336 0 102 if $tagInfo->{'LangCode'}
338 3 99 if ($tagInfo->{'List'} and $tagInfo->{'List'} ne 1)
345 443 3918 if $listType and $listType ne 1
348 252 4109 if ($strTable and not $parentID && ($tagTablePtr->{$parentID} && $tagTablePtr->{$parentID}{'NoSubStruct'} || length $parentID > 500))
355 21 231 if ref $strTable->{'NAMESPACE'}
359 545 2635 if $Image::ExifTool::XMP::specialStruct{$tag} or $strTable->{$tag}{'LangCode'}
360 1640 995 $parentID ? :
366 2635 1726 if ($structPtr)
369 1 2634 if $isType
383 0 1167 unless defined $val and @$propList > 2
384 1166 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( |$)/) { }
389 8 1158 unless @$propList > 3
391 0 1158 if ($propList->[-1] =~ /^rdf:(Bag|Seq|Alt)$/)
398 0 1158 if (defined $capture->{$path}) { }
434 0 30 unless defined $pre
437 12 18 unless ($prop eq $rdfDesc)
438 8 4 if ($post) { }
445 26 4 if (defined $post and length $post or defined $val and length $val)
459 2 2 unless $isWriting
472 8 8 unless $pre =~ m[/$rdfDesc/]
476 19 19 if ($isWriting) { }
485 4 4 if (%unused)
486 0 4 if $et->Options("Verbose")
490 4 4 if ($isWriting) { }
513 11474 15453 if not defined $ns or $nsUsed->{$ns}
515 0 15453 unless ($uri)
521 84607 0 unless $nsUsed->{$ns2} eq $uri
542 0 5 unless @props
544 3 2 if $doneID{$tagID}
547 0 2 unless ref $tagInfo eq "HASH"
548 1 1 if ($tagInfo->{'Struct'})
550 1 0 if ($type)
552 0 1 unless $pat
555 0 1 unless $path =~ /^($pat)/
557 1 0 if $basePath
558 1 0 unless $capture->{$p}
561 1 1 unless $tagInfo->{'StructType'}
573 0 0 if ($et->{'REQ_TAG_LOOKUP'}{'sphericalvideoxml'})
588 0 0 if ($dataPt and $$dataPt)
599 0 0 if ($xmp)
622 34 8 if $n > $chunkSize
630 8 0 if $pad < 3
631 0 8 if $_[1]
646 22 8070 if ($a =~ /rdf:type$/) { }
14 8056 elsif ($b =~ /rdf:type$/) { }
647 21 1 unless $b =~ /rdf:type$/
665 38 0 if length $$dataPt < $maxLen
672 0 0 if ($et->{'OPTIONS'}{'Compact'}{'Shorthand'}) { }
690 0 0 if $i xor $start >= $extStart
691 0 0 length($newData) + $descSize{$start} > $maxLen ? :
697 0 0 if (eval { do { require Digest::MD5 } })
718 1 1082 if ($$resFlag[@$curPropList]) { }
6 1076 elsif (defined $$resFlag[@$curPropList]) { }
720 1 0 if (length $short->[-1]) { }
721 0 1 if (length $long->[-1]) { }
733 0 0 length $long->[-1] ? :
735 0 1 if length $long->[-1]
741 3 3 if (length $long->[-1]) { }
750 309 767 unless (@$curPropList)
773 6496 130 unless $et
783 26 104 if not defined $dirLen and $dataPt
801 0 130 $compact{'NoIndent'} ? :
0 130 $compact{'NoNewline'} ? :
805 1 129 if (defined $et->{'NEW_VALUE'}{$tagInfo})
809 76 54 if ($xmpFile or $dirLen) { }
0 54 elsif (defined $about) { }
814 17 59 unless ($success and not $et->{'XMP_ERROR'})
817 17 0 if ($xmpFile) { }
820 0 17 if ($success or not $raf->Seek(0, 2) or $raf->Tell)
822 0 0 unless $et->{'XMP_ERROR'}
823 0 0 if ($et->Error($err, $success))
829 0 0 if $success and $success eq 1
830 0 0 if ($et->Warn($err, $success))
836 1 75 if (defined $about) { }
837 0 1 if ($verbose > 1)
839 0 0 if defined $wasAbout
850 0 76 if $xmpFile and $et->GetNewValue("ForceWrite")
852 0 76 if $et->{'FORCE_WRITE'}{'XMP'}
864 36 94 if ($xmpFile)
866 0 36 if ($tagInfo and $et->{'NEW_VALUE'}{$tagInfo})
869 0 0 if (defined $newVal and length $newVal)
872 0 0 unless &Write($dirInfo->{'OutFile'}, $newVal)
881 12 3 if (%{$et->{'DEL_GROUP'};} and grep(/^XMP-.+$/, keys %{$$et{'DEL_GROUP'};}) || grep(m[^http://ns.exiftool.(?:ca|org)/], values %nsUsed))
891 0 147 if $Image::ExifTool::XMP::stdXlatNS{$ns}
894 84 63 if ($nsUsed{$ns} and @g = $nsUsed{$ns} =~ m[^http://ns.exiftool.(?:ca|org)/(.*?)/(.*?)/]) { }
895 17 67 if ($g[1] =~ /^\d/) { }
899 10 7 unless $del->{$ucg} or $del->{'XML-*'} and not $$del{"-$ucg"}
902 19 25 unless $del->{$grp} or $$del{$g[0]} and not $$del{"-$grp"}
907 19 27 unless $del->{$ucg} or $del->{'XMP-*'} and not $$del{"-$ucg"}
916 1 129 if ($capture{$hasExtTag})
921 1 129 $et->{'XMP_NO_XMPMETA'} ? :
931 10834 4713 unless $et->GetGroup($tagInfo, 0) eq "XMP"
932 0 4713 if $tagInfo->{'Name'} eq "XMP"
933 0 4713 if $writeGroup and $writeGroup ne $et->{'NEW_VALUE'}{$tagInfo}{'WriteGroup'}
934 25 4688 if ($tagInfo->{'LangCode'}) { }
217 4471 elsif ($tagInfo->{'Struct'}) { }
942 14 116 if (@langTags)
945 0 25 if ($tagInfo->{'Struct'}) { }
956 0 4713 unless ($path)
961 2 4711 if ($path eq "rdf:about" or $path eq "x:xmptk")
977 2496 2085 if ($isStruct or defined $tagInfo->{'Flat'})
984 4984 6632 if ref $info eq "HASH" and $info->{'Struct'} and !@fixInfo || $fixInfo[0] ne $info
987 0 2496 unless @fixInfo
990 4364 217 unless @fixInfo and $isStruct
1002 2225 2674 if ($regex =~ s[\\/rdf\\:(Bag|Seq|Alt)\\/][/rdf:(Bag|Seq|Alt)/]g) { }
2091 583 elsif (not @fixInfo) { }
1004 2196 29 if ($regex =~ s[/rdf:\(Bag\|Seq\|Alt\)\/rdf\\:li\\ \\d\+$][])
1005 368 1828 unless @fixInfo
1012 2418 2481 if (@fixInfo)
1017 4577 322 unless @matches
1018 317 5 if ($matches[0] =~ /^$ok$/)
1019 0 317 unless (@fixInfo)
1030 1 6 if $ok2 and $#matchProps > $#fixProps
1032 0 19 unless defined $matchProps[$i]
1033 15 4 if $matchProps[$i] =~ / \d+$/ or $matchProps[$i] eq $fixProps[$i]
1037 0 7 if $fixed{$fixed} or $capture{$fixed} and $match ne $fixed
1042 2 3 lc $fixed[0] eq lc $matches[0] ? :
1043 0 5 if ($err) { }
1050 2 5 if $fixed eq $match
1054 1 4 if $ok2 and not $match =~ /^$ok2$/
1057 4 1 unless @fixInfo
1058 3 2 if ($didFix)
1071 169 4542 if ($writable eq "lang-alt")
1073 7 162 if ($delLangPath and $delLangPath eq $path) { }
1075 2 5 if $delLangPaths{$newLang}
1082 2 167 if (%delAllLang)
1086 5 1 if grep /^$prefix/, @delPaths
1090 1 1 if $reSort
1094 217 4494 if ($isStruct) { }
132 4362 elsif ($cap) { }
1099 49 138 if not $existed || $nvHash->{'IsCreating'} and $tagInfo->{'Avoid'}
1100 0 215 unless $deleted or $added or $et->IsOverwriting($nvHash)
1101 2 2 if $existed and $nvHash->{'CreateOnly'}
1103 2 130 if $nvHash->{'CreateOnly'}
1106 126 4 if ($overwrite) { }
1109 44 82 if ($path =~ / /) { }
1119 60 121 if ($writable eq 'lang-alt') { }
7 114 elsif ($overwrite < 0) { }
1123 38 22 unless ($langPathPat and $path =~ /^$langPathPat$/)
1129 24 36 unless (defined $addLang)
1131 21 3 $nvHash->{'IsCreating'} ? :
1133 13 47 if ($overwrite < 0)
1134 5 8 unless $oldLang eq $newLang
1138 5 3 unless $addLang
1142 13 37 if ($oldLang eq 'x-default' and not $tagInfo->{'LangCode'}) { }
31 12 elsif ($tagInfo->{'LangCode'} and not $delLang) { }
1147 27 4 unless lc $tagInfo->{'LangCode'} eq $oldLang
1151 3 4 if ($nvHash->{'Shift'})
1155 1 2 if ($fmt eq 'rational') { }
2 0 elsif ($fmt eq 'date') { }
1162 1 6 unless $et->IsOverwriting($nvHash, &UnescapeXML($val))
1164 0 143 if ($verbose > 1)
1167 0 0 if $tagInfo->{'LangCode'}
1168 0 0 if $attrs->{'xml:lang'}
1173 116 27 unless @delPaths
1174 23 120 if ($writable eq "lang-alt")
1179 137 6 if ($writable ne 'lang-alt' or $oldLang eq $newLang) { }
1182 3 3 unless $delLangPaths{$oldLang}
1186 19 124 if ($delLang)
1195 0 143 if ($path =~ m[^(.*)/] and $capture{"$1/rdf:type"})
1198 0 0 if @a == 1
1201 1 7 unless @delPaths or $tagInfo->{'List'} or $addLang
1202 118 7 if (@delPaths) { }
1206 0 0 unless $path =~ s/ \d(\d+)$/' ' . length($1 + 1) . ($1 + 1);/e
1212 0 7 unless $tagInfo->{'List'} or $oldLang
1214 7 0 if ($writable eq "lang-alt" and %langsHere)
1216 0 9 unless $path =~ /^$_$/
1217 6 3 unless $langsHere{$_}{$newLang}
1218 0 3 unless $path =~ /(.* )\d(\d+)(.*? \d+)$/
1224 0 7 unless $path =~ /.* (\d+)/g
1231 2 2 if ($writable eq "lang-alt")
1232 1 1 if ($firstNewPath) { }
1239 4 0 if ($path =~ /$pat/g)
1242 1 3 if $2
1245 11 118 if (defined $added)
1251 2 9 if ($overwrite and $writable eq 'lang-alt' and !$tagInfo->{'LangCode'} || $tagInfo->{'LangCode'} eq 'x-default') { }
1261 1 0 unless $nextCap
1284 1861 2596 unless $deleted or defined $added or not $cap and $isCreating
1289 1924 921 unless my(@newValues) = $et->GetNewValue($nvHash)
1292 73 848 if ($writable eq "lang-alt")
1294 9 64 if defined $added
1300 30 1015 if ($isStruct) { }
1302 30 0 if &AddNewStruct($et, $tagInfo, \%capture, $path, $newValue, $tagInfo->{'Struct'})
1306 3 1012 if ($tagInfo->{'Resource'})
1308 3 0 unless ($newValue =~ m<[^a-z0-9\:/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~]>i)
1322 1 1014 if ($verbose > 1)
1328 0 1015 if ($tagInfo->{'StructType'})
1332 921 124 unless @newValues
1335 22 102 $writable eq 'lang-alt' ? :
1337 0 124 unless $path =~ /$pat/g
1340 22 102 $2 ? :
1342 52 72 if ($subIdx) { }
19 53 elsif (@delPaths) { }
1350 0 2 unless $path =~ s/ \d(\d+)$/' ' . length($1 + 1) . ($1 + 1);/e
1360 344 577 if (defined $tagInfo->{'Flat'})
1363 490 0 unless $capture{$p}
1365 0 0 if $capture{$p}[0] =~ /\S/
1379 3 0 unless ($changed or $maxDataLen and $dataPt and defined $$dataPt and length $$dataPt > $maxDataLen)
1382 19 0 unless $xmpFile
1383 0 0 if $dataPt and defined $$dataPt
1392 1 110 if ($et->{'XMP_NO_XPACKET'}) { }
1394 0 1 if $et->{'XMP_NO_XPACKET'} == 2
1398 1 110 if $et->{'XMP_IS_XML'}
1406 36 75 if ($maxDataLen and @pathList)
1413 108 301 if ($1 eq $lastProp) { }
1417 14 287 if ($extendedRes{$lastProp} or $extendedRes{$lastNS} or $propSize > $newDescThresh) { }
1424 36 265 unless $path
1435 115 1876 unless (@pathList)
1436 111 4 unless @writeLast
1447 0 5699 unless $prop =~ /(.*):/
1448 3202 2497 if $1 eq "rdf"
1450 1479 1018 unless ($uri)
1452 0 1479 unless ($uri)
1454 0 0 if (length $1)
1456 0 0 if (not $xmpErr or $err ne $xmpErr)
1457 0 0 $xmpFile ? :
1466 380 2117 unless $nsCur{$1}
1469 315 1565 if ($newDesc) { }
1477 0 1769 $compact{'OneDesc'} ? :
1479 1060 2321 if $ns2 eq "rdf"
1480 2104 217 if $nsNew{$ns2}
1481 204 13 unless $opening
1483 0 13 unless my $uri = $nsUsed{$ns2} || $Image::ExifTool::XMP::nsURI{$ns2}
1486 204 1565 unless $opening
1491 0 2971 unless $closeTo < @propList
1492 238 2733 unless $propList[$closeTo] eq $curPropList[$closeTo]
1499 315 1565 if ($newDesc)
1500 0 315 if $newDesc == 2
1502 107 208 if $maxDataLen
1509 4 1 if ($et->{'XMP_NO_XMPMETA'} and @ns and $nsCur{$ns[0]} =~ m[^http://ns.exiftool.(?:ca|org)/])
1516 6 309 if $compact{'Shorthand'}
1519 0 1880 if $debug
1528 0 771 $compact{'NoIndent'} ? :
1529 139 632 if ($prop ne $rdfDesc and !($propList[$n + 1] =~ /^rdf:/) || $propList[$n + 1] eq 'rdf:type' && $n + 1 == $#propList) { }
1533 3 136 if ($propList[$n + 1] =~ /:~dummy~$/)
1539 1 135 if ($compact{'Shorthand'}) { }
1553 1877 0 unless ($dummy or $val eq "" and $prop2 =~ /:~dummy~$/)
1555 0 1877 $compact{'NoIndent'} ? :
1557 19 1858 if (defined $resFlag[$#curPropList] and not %$attrs and not $val =~ /
1564 0 209 $attrVal =~ /'/ ? :
1567 1824 34 length $val ? :
1575 38 73 if ($maxDataLen)
1578 38 0 unless $extStart
1584 0 38 if length($long[-2]) + 101 * $numPadLines > $maxDataLen
1586 0 111 if $dirInfo->{'Compact'}
1591 110 1 unless $et->{'XMP_NO_XMPMETA'}
1600 110 1 unless ($et->{'XMP_NO_XPACKET'})
1604 0 110 if ($dirInfo->{'InPlace'} and not $dirInfo->{'InPlace'} == 2 && $len > $dirLen) { }
69 41 elsif (not $compact{'NoPadding'} || $xmpFile || $dirInfo->{'ReadOnly'}) { }
1606 0 0 if ($len > $dirLen)
1608 0 0 unless $compact{'Shorthand'}
1613 0 0 if ($num)
1617 0 0 if $len < $dirLen
1621 6 104 $dirInfo->{'ReadOnly'} ? :
1624 3 1 unless (%capture or $xmpFile or $dirInfo->{'InPlace'} or $dirInfo->{'NoDelete'})
1627 0 0 $xmpFile ? :
0 111 if $xmpErr
1629 0 0 if $debug > 1 and $long[-2]
1630 75 36 unless $xmpFile
1631 0 36 unless &Write($dirInfo->{'OutFile'}, $long[-2])