Branch Coverage

blib/lib/Image/ExifTool/WriteXMP.pl
Criterion Covered Total %
branch 454 648 70.0


line true false branch
59 1 122 if (defined $nv) { }
61 1 0 $tk ? :
66 123 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 98 2447 if ($tagInfo->{'Struct'})
178 76 22 unless (ref $$valPtr)
181 64 12 unless (ref $$valPtr)
182 0 64 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 1325 if ($et->{'OPTIONS'}{'Charset'} ne 'UTF8') { }
212 4 0 if ($$valPtr =~ /[\x80-\xff]/)
220 0 1325 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 1655 7123 unless $tagInfo->{'PropertyPath'}
294 0 4042 if ref $tagInfo ne "HASH"
296 2327 1715 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 1715 if $tagInfo->{'PropertyPath'}
315 3 1712 if $srcInfo
316 3 1712 if $tagInfo->{'PropertyPath'}
318 60 1652 if ($tagInfo->{'RootTagInfo'})
320 60 0 if $tagInfo->{'PropertyPath'}
326 0 3979 unless $ns
328 2327 1652 if $propList
331 102 3877 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 3561 if $listType and $listType ne 1
346 231 3748 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 1652 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 13786 if not defined $ns or $nsUsed->{$ns}
513 0 13786 unless ($uri)
519 74033 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'}
571 0 0 if ($et->{'REQ_TAG_LOOKUP'}{'sphericalvideoxml'})
586 0 0 if ($dataPt and $$dataPt)
597 0 0 if ($xmp)
620 34 8 if $n > $chunkSize
628 8 0 if $pad < 3
629 0 8 if $_[1]
644 8 7876 if ($a =~ /rdf:type$/) { }
11 7865 elsif ($b =~ /rdf:type$/) { }
645 7 1 unless $b =~ /rdf:type$/
663 36 0 if length $$dataPt < $maxLen
670 0 0 if ($et->{'OPTIONS'}{'Compact'}{'Shorthand'}) { }
688 0 0 if $i xor $start >= $extStart
689 0 0 length($newData) + $descSize{$start} > $maxLen ? :
695 0 0 if (eval { do { require Digest::MD5 } })
716 1 1065 if ($$resFlag[@$curPropList]) { }
6 1059 elsif (defined $$resFlag[@$curPropList]) { }
718 1 0 if (length $short->[-1]) { }
719 0 1 if (length $long->[-1]) { }
731 0 0 length $long->[-1] ? :
733 0 1 if length $long->[-1]
739 3 3 if (length $long->[-1]) { }
748 301 758 unless (@$curPropList)
771 6058 124 unless $et
781 26 98 if not defined $dirLen and $dataPt
799 0 124 $compact{'NoIndent'} ? :
0 124 $compact{'NoNewline'} ? :
803 1 123 if (defined $et->{'NEW_VALUE'}{$tagInfo})
807 72 52 if ($xmpFile or $dirLen) { }
0 52 elsif (defined $about) { }
812 16 56 unless ($success and not $et->{'XMP_ERROR'})
815 16 0 if ($xmpFile) { }
818 0 16 if ($success or not $raf->Seek(0, 2) or $raf->Tell)
820 0 0 unless $et->{'XMP_ERROR'}
821 0 0 if ($et->Error($err, $success))
827 0 0 if $success and $success eq 1
828 0 0 if ($et->Warn($err, $success))
834 1 71 if (defined $about) { }
835 0 1 if ($verbose > 1)
837 0 0 if defined $wasAbout
848 0 72 if $xmpFile and $et->GetNewValue("ForceWrite")
850 0 72 if $et->{'FORCE_WRITE'}{'XMP'}
862 35 89 if ($xmpFile)
864 0 35 if ($tagInfo and $et->{'NEW_VALUE'}{$tagInfo})
867 0 0 if (defined $newVal and length $newVal)
870 0 0 unless &Write($dirInfo->{'OutFile'}, $newVal)
879 12 2 if (%{$et->{'DEL_GROUP'};} and grep(/^XMP-.+$/, keys %{$$et{'DEL_GROUP'};}) || grep(m[^http://ns.exiftool.(?:ca|org)/], values %nsUsed))
889 0 141 if $Image::ExifTool::XMP::stdXlatNS{$ns}
892 78 63 if ($nsUsed{$ns} and @g = $nsUsed{$ns} =~ m[^http://ns.exiftool.(?:ca|org)/(.*?)/(.*?)/]) { }
893 20 58 if ($g[1] =~ /^\d/) { }
897 13 7 unless $del->{$ucg} or $del->{'XML-*'} and not $$del{"-$ucg"}
900 18 18 unless $del->{$grp} or $$del{$g[0]} and not $$del{"-$grp"}
905 19 27 unless $del->{$ucg} or $del->{'XMP-*'} and not $$del{"-$ucg"}
914 1 123 if ($capture{$hasExtTag})
919 1 123 $et->{'XMP_NO_XMPMETA'} ? :
929 10728 4311 unless $et->GetGroup($tagInfo, 0) eq "XMP"
930 0 4311 if $tagInfo->{'Name'} eq "XMP"
931 0 4311 if $writeGroup and $writeGroup ne $et->{'NEW_VALUE'}{$tagInfo}{'WriteGroup'}
932 196 4115 if ($tagInfo->{'Struct'}) { }
942 0 4311 unless ($path)
947 2 4309 if ($path eq "rdf:about" or $path eq "x:xmptk")
963 2173 2006 if ($isStruct or defined $tagInfo->{'Flat'})
970 4286 5750 if ref $info eq "HASH" and $info->{'Struct'} and !@fixInfo || $fixInfo[0] ne $info
973 0 2173 unless @fixInfo
976 3983 196 unless @fixInfo and $isStruct
988 1971 2483 if ($regex =~ s[\\/rdf\\:(Bag|Seq|Alt)\\/][/rdf:(Bag|Seq|Alt)/]g) { }
2005 478 elsif (not @fixInfo) { }
990 1958 13 if ($regex =~ s[/rdf:\(Bag\|Seq\|Alt\)\/rdf\\:li\\ \\d\+$][])
991 353 1605 unless @fixInfo
998 2083 2371 if (@fixInfo)
1003 4175 279 unless @matches
1004 274 5 if ($matches[0] =~ /^$ok$/)
1005 0 274 unless (@fixInfo)
1016 1 6 if $ok2 and $#matchProps > $#fixProps
1018 0 19 unless defined $matchProps[$i]
1019 15 4 if $matchProps[$i] =~ / \d+$/ or $matchProps[$i] eq $fixProps[$i]
1023 0 7 if $fixed{$fixed} or $capture{$fixed} and $match ne $fixed
1028 2 3 lc $fixed[0] eq lc $matches[0] ? :
1029 0 5 if ($err) { }
1036 2 5 if $fixed eq $match
1040 1 4 if $ok2 and not $match =~ /^$ok2$/
1043 4 1 unless @fixInfo
1044 3 2 if ($didFix)
1057 169 4140 if ($writable eq "lang-alt")
1059 7 162 if ($delLangPath and $delLangPath eq $path) { }
1061 2 5 if $delLangPaths{$newLang}
1068 2 167 if (%delAllLang)
1072 5 1 if grep /^$prefix/, @delPaths
1076 1 1 if $reSort
1080 196 4113 if ($isStruct) { }
132 3981 elsif ($cap) { }
1084 0 194 unless $deleted or $added or $et->IsOverwriting($nvHash)
1085 2 2 if $existed and $nvHash->{'CreateOnly'}
1087 2 130 if $nvHash->{'CreateOnly'}
1090 126 4 if ($overwrite) { }
1093 44 82 if ($path =~ / /) { }
1103 60 121 if ($writable eq 'lang-alt') { }
7 114 elsif ($overwrite < 0) { }
1107 38 22 unless ($langPathPat and $path =~ /^$langPathPat$/)
1113 24 36 unless (defined $addLang)
1115 21 3 $nvHash->{'IsCreating'} ? :
1117 13 47 if ($overwrite < 0)
1118 5 8 unless $oldLang eq $newLang
1122 5 3 unless $addLang
1126 13 37 if ($oldLang eq 'x-default' and not $tagInfo->{'LangCode'}) { }
31 12 elsif ($tagInfo->{'LangCode'} and not $delLang) { }
1131 27 4 unless lc $tagInfo->{'LangCode'} eq $oldLang
1135 3 4 if ($nvHash->{'Shift'})
1139 1 2 if ($fmt eq 'rational') { }
2 0 elsif ($fmt eq 'date') { }
1146 1 6 unless $et->IsOverwriting($nvHash, &UnescapeXML($val))
1148 0 143 if ($verbose > 1)
1151 0 0 if $tagInfo->{'LangCode'}
1152 0 0 if $attrs->{'xml:lang'}
1157 116 27 unless @delPaths
1158 23 120 if ($writable eq "lang-alt")
1163 137 6 if ($writable ne 'lang-alt' or $oldLang eq $newLang) { }
1166 3 3 unless $delLangPaths{$oldLang}
1170 19 124 if ($delLang)
1179 0 143 if ($path =~ m[^(.*)/] and $capture{"$1/rdf:type"})
1182 0 0 if @a == 1
1185 1 7 unless @delPaths or $tagInfo->{'List'} or $addLang
1186 118 7 if (@delPaths) { }
1190 0 0 unless $path =~ s/ \d(\d+)$/" " . length($1 + 1) . ($1 + 1);/e
1196 0 7 unless $tagInfo->{'List'} or $oldLang
1198 7 0 if ($writable eq "lang-alt" and %langsHere)
1200 0 9 unless $path =~ /^$_$/
1201 6 3 unless $langsHere{$_}{$newLang}
1202 0 3 unless $path =~ /(.* )\d(\d+)(.*? \d+)$/
1208 0 7 unless $path =~ /.* (\d+)/g
1215 2 2 if ($writable eq "lang-alt")
1216 1 1 if ($firstNewPath) { }
1223 4 0 if ($path =~ /$pat/g)
1226 1 3 if $2
1229 11 118 if (defined $added)
1235 2 9 if ($overwrite and $writable eq 'lang-alt' and !$tagInfo->{'LangCode'} || $tagInfo->{'LangCode'} eq 'x-default') { }
1245 1 0 unless $nextCap
1268 1644 2385 unless $deleted or defined $added or not $cap and $isCreating
1273 1781 879 unless my(@newValues) = $et->GetNewValue($nvHash)
1276 73 806 if ($writable eq "lang-alt")
1278 9 64 if defined $added
1284 30 971 if ($isStruct) { }
1286 30 0 if &AddNewStruct($et, $tagInfo, \%capture, $path, $newValue, $tagInfo->{'Struct'})
1290 3 968 if ($tagInfo->{'Resource'})
1292 3 0 unless ($newValue =~ m<[^a-z0-9\:/\?\#\[\]\@\!\$\&\'\(\)\*\+\,\;\=\.\-\_\~]>i)
1306 1 970 if ($verbose > 1)
1312 0 971 if ($tagInfo->{'StructType'})
1316 879 122 unless @newValues
1319 22 100 $writable eq 'lang-alt' ? :
1321 0 122 unless $path =~ /$pat/g
1324 22 100 $2 ? :
1326 51 71 if ($subIdx) { }
19 52 elsif (@delPaths) { }
1334 0 2 unless $path =~ s/ \d(\d+)$/" " . length($1 + 1) . ($1 + 1);/e
1344 318 561 if (defined $tagInfo->{'Flat'})
1347 420 0 unless $capture{$p}
1349 0 0 if $capture{$p}[0] =~ /\S/
1363 3 0 unless ($changed or $maxDataLen and $dataPt and defined $$dataPt and length $$dataPt > $maxDataLen)
1366 16 0 unless $xmpFile
1367 0 0 if $dataPt and defined $$dataPt
1376 1 107 if ($et->{'XMP_NO_XPACKET'}) { }
1378 0 1 if $et->{'XMP_NO_XPACKET'} == 2
1382 1 107 if $et->{'XMP_IS_XML'}
1390 34 74 if ($maxDataLen and @pathList)
1397 95 284 if ($1 eq $lastProp) { }
1401 14 270 if ($extendedRes{$lastProp} or $extendedRes{$lastNS} or $propSize > $newDescThresh) { }
1408 34 250 unless $path
1419 112 1834 unless (@pathList)
1420 108 4 unless @writeLast
1431 0 5539 unless $prop =~ /(.*):/
1432 3132 2407 if $1 eq "rdf"
1434 1387 1020 unless ($uri)
1436 0 1387 unless ($uri)
1438 0 0 if (length $1)
1440 0 0 if (not $xmpErr or $err ne $xmpErr)
1441 0 0 $xmpFile ? :
1450 371 2036 unless $nsCur{$1}
1453 307 1531 if ($newDesc) { }
1461 0 1730 $compact{'OneDesc'} ? :
1463 1030 2235 if $ns2 eq "rdf"
1464 2024 211 if $nsNew{$ns2}
1465 199 12 unless $opening
1467 0 12 unless my $uri = $nsUsed{$ns2} || $Image::ExifTool::XMP::nsURI{$ns2}
1470 199 1531 unless $opening
1475 0 2866 unless $closeTo < @propList
1476 234 2632 unless $propList[$closeTo] eq $curPropList[$closeTo]
1483 307 1531 if ($newDesc)
1484 0 307 if $newDesc == 2
1486 100 207 if $maxDataLen
1493 4 1 if ($et->{'XMP_NO_XMPMETA'} and @ns and $nsCur{$ns[0]} =~ m[^http://ns.exiftool.(?:ca|org)/])
1500 6 301 if $compact{'Shorthand'}
1503 0 1838 if $debug
1512 0 762 $compact{'NoIndent'} ? :
1513 134 628 if ($prop ne $rdfDesc and !($propList[$n + 1] =~ /^rdf:/) || $propList[$n + 1] eq 'rdf:type' && $n + 1 == $#propList) { }
1517 3 131 if ($propList[$n + 1] =~ /:~dummy~$/)
1523 1 130 if ($compact{'Shorthand'}) { }
1537 1835 0 unless ($dummy or $val eq "" and $prop2 =~ /:~dummy~$/)
1539 0 1835 $compact{'NoIndent'} ? :
1541 19 1816 if (defined $resFlag[$#curPropList] and not %$attrs and not $val =~ /
1548 0 211 $attrVal =~ /'/ ? :
1551 1782 34 length $val ? :
1559 36 72 if ($maxDataLen)
1562 36 0 unless $extStart
1568 0 36 if length($long[-2]) + 101 * $numPadLines > $maxDataLen
1570 0 108 if $dirInfo->{'Compact'}
1575 107 1 unless $et->{'XMP_NO_XMPMETA'}
1584 107 1 unless ($et->{'XMP_NO_XPACKET'})
1588 0 107 if ($dirInfo->{'InPlace'} and not $dirInfo->{'InPlace'} == 2 && $len > $dirLen) { }
67 40 elsif (not $compact{'NoPadding'} || $xmpFile || $dirInfo->{'ReadOnly'}) { }
1590 0 0 if ($len > $dirLen)
1592 0 0 unless $compact{'Shorthand'}
1597 0 0 if ($num)
1601 0 0 if $len < $dirLen
1605 6 101 $dirInfo->{'ReadOnly'} ? :
1608 3 1 unless (%capture or $xmpFile or $dirInfo->{'InPlace'} or $dirInfo->{'NoDelete'})
1611 0 0 $xmpFile ? :
0 108 if $xmpErr
1613 0 0 if $debug > 1 and $long[-2]
1614 73 35 unless $xmpFile
1615 0 35 unless &Write($dirInfo->{'OutFile'}, $long[-2])