Image/ExifTool/Validate.pm

filter: Statementstmt 53.9% 116 / 215 Branchbran 33.6% 64 / 190 Conditioncond 38.1% 77 / 202 MC/DCmcdc 8.9% 9 / 101 Subroutinesub 81.8% 9 / 11 Podpod 0.0% 0 / 6 totaltotal 37.9% 275 / 725 CC 167 SCAR 61.8
CC
167
Cov
42%
FinishValidate
1191.2
ValidateExif
422.2
ValidateXMPDate
182.0
CRAP 483.3
« Image/ExifTool/WritePDF.pl ↑ Summary Image/ExifTool/MacOS.pm »
1 #------------------------------------------------------------------------------
2 # File: Validate.pm
3 #
4 # Description: Additional metadata validation
5 #
6 # Created: 2017/01/18 - P. Harvey
7 #
8 # Notes: My apologies for the convoluted logic contained herein, but it
9 # is done this way to retro-fit the Validate feature into the
10 # existing ExifTool code while reducing the possibility of
11 # introducing bugs or slowing down processing when this feature
12 # is not used.
13 #------------------------------------------------------------------------------
14  
15 package Image::ExifTool::Validate;
16  
17 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶use vars qw($VERSION %exifSpec);
Subroutine BEGIN: called CC=1 SCAR=0.0
19  
20 1 $VERSION = '1.26';
21  
22 1 ▶use Image::ExifTool qw(:Utils);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 ▶use Image::ExifTool::Exif;
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 # EXIF table tag ID's which are part of the EXIF 2.32 specification
26 # (with ExifVersion numbers for tags where I can determine the version)
27 # (also used by BuildTagLookup to add underlines in HTML version of EXIF Tag Table)
28 1 %exifSpec = (
29 0x1 => 210,
30 0x100 => 1, 0x8298 => 1, 0x9207 => 1, 0xa217 => 1,
31 0x101 => 1, 0x829a => 1, 0x9208 => 1, 0xa300 => 1,
32 0x102 => 1, 0x829d => 1, 0x9209 => 1, 0xa301 => 1,
33 0x103 => 1, 0x8769 => 1, 0x920a => 1, 0xa302 => 1,
34 0x106 => 1, 0x8822 => 1, 0x9214 => 220, 0xa401 => 220,
35 0x10e => 1, 0x8824 => 1, 0x927c => 1, 0xa402 => 220,
36 0x10f => 1, 0x8825 => 200, 0x9286 => 1, 0xa403 => 220,
37 0x110 => 1, 0x8827 => 1, 0x9290 => 1, 0xa404 => 220,
38 0x111 => 1, 0x8828 => 1, 0x9291 => 1, 0xa405 => 220,
39 0x112 => 1, 0x8830 => 230, 0x9292 => 1, 0xa406 => 220,
40 0x115 => 1, 0x8831 => 230, 0x9400 => 231, 0xa407 => 220,
41 0x116 => 1, 0x8832 => 230, 0x9401 => 231, 0xa408 => 220,
42 0x117 => 1, 0x8833 => 230, 0x9402 => 231, 0xa409 => 220,
43 0x11a => 1, 0x8834 => 230, 0x9403 => 231, 0xa40a => 220,
44 0x11b => 1, 0x8835 => 230, 0x9404 => 231, 0xa40b => 220,
45 0x11c => 1, 0x9000 => 1, 0x9405 => 231, 0xa40c => 220,
46 0x128 => 1, 0x9003 => 1, 0xa000 => 1, 0xa460 => 232,
47 0x12d => 1, 0x9004 => 1, 0xa001 => 1, 0xa461 => 232,
48 0x131 => 1, 0x9010 => 231, 0xa002 => 1, 0xa462 => 232,
49 0x132 => 1, 0x9011 => 231, 0xa003 => 1, 0xa420 => 220,
50 0x13b => 1, 0x9012 => 231, 0xa004 => 1, 0xa430 => 230,
51 0x13e => 1, 0x9101 => 1, 0xa005 => 210, 0xa431 => 230,
52 0x13f => 1, 0x9102 => 1, 0xa20b => 1, 0xa432 => 230,
53 0x201 => 1, 0x9201 => 1, 0xa20c => 1, 0xa433 => 230,
54 0x202 => 1, 0x9202 => 1, 0xa20e => 1, 0xa434 => 230,
55 0x211 => 1, 0x9203 => 1, 0xa20f => 1, 0xa435 => 230,
56 0x212 => 1, 0x9204 => 1, 0xa210 => 1, 0xa500 => 221,
57 0x213 => 1, 0x9205 => 1, 0xa214 => 1,
58 0x214 => 1, 0x9206 => 1, 0xa215 => 1,
59  
60 # new Exif 3.0 tags
61 0xa436 => 300,
62 0xa437 => 300,
63 0xa438 => 300,
64 0xa439 => 300,
65 0xa43a => 300,
66 0xa43b => 300,
67 0xa43c => 300,
68 );
69  
70 # GPSVersionID numbers when each tag was introduced
71 1 my %gpsVer = (
72 0x01 => 2000, 0x09 => 2000, 0x11 => 2000, 0x19 => 2000,
73 0x02 => 2000, 0x0a => 2000, 0x12 => 2000, 0x1a => 2000,
74 0x03 => 2000, 0x0b => 2000, 0x13 => 2000, 0x1b => 2200,
75 0x04 => 2000, 0x0c => 2000, 0x14 => 2000, 0x1c => 2200,
76 0x05 => 2000, 0x0d => 2000, 0x15 => 2000, 0x1d => 2200,
77 0x06 => 2000, 0x0e => 2000, 0x16 => 2000, 0x1e => 2200,
78 0x07 => 2000, 0x0f => 2000, 0x17 => 2000, 0x1f => 2300,
79 0x08 => 2000, 0x10 => 2000, 0x18 => 2000,
80 );
81  
82 # lookup to check version numbers
83 1 my %verCheck = (
84 ExifIFD => { ExifVersion => \%exifSpec },
85 InteropIFD => { ExifVersion => \%exifSpec },
86 GPS => { GPSVersionID => \%gpsVer },
87 );
88  
89 # tags standard in various RAW file formats or IFD's
90 1 my %otherSpec = (
91 CR2 => { 0xc5d8 => 1, 0xc5d9 => 1, 0xc5e0 => 1, 0xc640 => 1, 0xc6dc => 1, 0xc6dd => 1 },
92 NEF => { 0x9216 => 1, 0x9217 => 1 },
93 DNG => { 0x882a => 1, 0x9211 => 1, 0x9216 => 1 },
94 ARW => { 0x7000 => 1, 0x7001 => 1, 0x7010 => 1, 0x7011 => 1, 0x7020 => 1, 0x7031 => 1,
95 0x7032 => 1, 0x7034 => 1, 0x7035 => 1, 0x7036 => 1, 0x7037 => 1, 0x7038 => 1,
96 0x7310 => 1, 0x7313 => 1, 0x7316 => 1, 0x74c7 => 1, 0x74c8 => 1, 0xa500 => 1 },
97 RW2 => { All => 1 }, # ignore all unknown tags in RW2
98 RWL => { All => 1 },
99 RAF => { All => 1 }, # (temporary)
100 DCR => { All => 1 },
101 KDC => { All => 1 },
102 JXR => { All => 1 },
103 SRW => { 0xa010 => 1, 0xa011 => 1, 0xa101 => 1, 0xa102 => 1 },
104 NRW => { 0x9216 => 1, 0x9217 => 1 },
105 X3F => { 0xa500 => 1 },
106 CameraIFD => { All => 1 }, # (exists in JPG and DNG of Leica Q3 images)
107 );
108  
109 # standard format for tags (not necessary for exifSpec or GPS tags where Writable is defined)
110 1 my %stdFormat = (
111 ExifIFD => {
112 0xa002 => 'int(16|32)u',
113 0xa003 => 'int(16|32)u',
114 },
115 InteropIFD => {
116 0x01 => 'string',
117 0x02 => 'undef',
118 0x1000 => 'string',
119 0x1001 => 'int(16|32)u',
120 0x1002 => 'int(16|32)u',
121 },
122 IFD => {
123 # TIFF, EXIF, XMP, IPTC, ICC_Profile and PrintIM standard tags:
124 0xfe => 'int32u', 0x11f => 'rational64u', 0x14a => 'int32u', 0x205 => 'int16u',
125 0xff => 'int16u', 0x120 => 'int32u', 0x14c => 'int16u', 0x206 => 'int16u',
126 0x100 => 'int(16|32)u', 0x121 => 'int32u', 0x14d => 'string', 0x207 => 'int32u',
127 0x101 => 'int(16|32)u', 0x122 => 'int16u', 0x14e => 'int16u', 0x208 => 'int32u',
128 0x107 => 'int16u', 0x123 => 'int16u', 0x150 => 'int(8|16)u', 0x209 => 'int32u',
129 0x108 => 'int16u', 0x124 => 'int32u', 0x151 => 'string', 0x211 => 'rational64u',
130 0x109 => 'int16u', 0x125 => 'int32u', 0x152 => 'int16u', 0x212 => 'int16u',
131 0x10a => 'int16u', 0x129 => 'int16u', 0x153 => 'int16u', 0x213 => 'int16u',
132 0x10d => 'string', 0x13c => 'string', 0x154 => '.*', 0x214 => 'rational64u',
133 0x111 => 'int(16|32)u', 0x13d => 'int16u', 0x155 => '.*', 0x2bc => 'int8u',
134 0x116 => 'int(16|32)u', 0x140 => 'int16u', 0x156 => 'int16u', 0x828d => 'int16u',
135 0x117 => 'int(16|32)u', 0x141 => 'int16u', 0x15b => 'undef', 0x828e => 'int8u',
136 0x118 => 'int16u', 0x142 => 'int(16|32)u', 0x200 => 'int16u', 0x83bb => 'int32u',
137 0x119 => 'int16u', 0x143 => 'int(16|32)u', 0x201 => 'int32u', 0x8649 => 'int8u',
138 0x11d => 'string', 0x144 => 'int32u', 0x202 => 'int32u', 0x8773 => 'undef',
139 0x11e => 'rational64u', 0x145 => 'int(16|32)u', 0x203 => 'int16u', 0xc4a5 => 'undef',
140 # Windows Explorer tags:
141 0x9c9b => 'int8u', 0x9c9d => 'int8u', 0x9c9f => 'int8u',
142 0x9c9c => 'int8u', 0x9c9e => 'int8u',
143 # GeoTiff tags:
144 0x830e => 'double', 0x8482 => 'double', 0x87af => 'int16u', 0x87b1 => 'string',
145 0x8480 => 'double', 0x85d8 => 'double', 0x87b0 => 'double',
146 # DNG tags: (use '' for non-DNG tags in the range 0xc612-0xcd48)
147 0xc615 => '(string|int8u)', 0xc6f4 => '(string|int8u)', 0xcd49 => 'float',
148 0xc61a => '(int16u|int32u|rational64u)', 0xc6f6 => '(string|int8u)', 0xcd4a => 'int32u',
149 0xc61d => 'int(16|32)u', 0xc6f8 => '(string|int8u)', 0xcd4b => 'int32u',
150 0xc61f => '(int16u|int32u|rational64u)', 0xc6fe => '(string|int8u)',
151 0xc620 => '(int16u|int32u|rational64u)', 0xc716 => '(string|int8u)',
152 0xc628 => '(int16u|rational64u)', 0xc717 => '(string|int8u)',
153 0xc634 => 'int8u', 0xc718 => '(string|int8u)',
154 0xc640 => '', 0xc71e => 'int(16|32)u',
155 0xc660 => '', 0xc71f => 'int(16|32)u',
156 0xc68b => '(string|int8u)', 0xc791 => 'int(16|32)u',
157 0xc68d => 'int(16|32)u', 0xc792 => 'int(16|32)u',
158 0xc68e => 'int(16|32)u', 0xc793 => '(int16u|int32u|rational64u)',
159 0xc6d2 => '', 0xcd43 => 'int(16|32)u',
160 0xc6d3 => '', 0xcd48 => '(string|int8u)',
161  
162 # Exif 3.0 spec
163 0x10e => 'string|utf8', 0xa430 => 'string|utf8', 0xa439 => 'string|utf8',
164 0x10f => 'string|utf8', 0xa433 => 'string|utf8', 0xa43a => 'string|utf8',
165 0x110 => 'string|utf8', 0xa434 => 'string|utf8', 0xa43b => 'string|utf8',
166 0x131 => 'string|utf8', 0xa436 => 'string|utf8', 0xa43c => 'string|utf8',
167 0x13b => 'string|utf8', 0xa437 => 'string|utf8', 0xa43a => 'string|utf8',
168 0x8298 => 'string|utf8', 0xa438 => 'string|utf8',
169 },
170 );
171  
172 # generate lookup for any IFD
173 1 my %stdFormatAnyIFD = map { %{$stdFormat{$_}} } keys %stdFormat;
174  
175 # tag values to validate based on file type (from EXIF specification)
176 # - validation code may access $val and %val, and returns 1 on success,
177 # or error message otherwise ('' for a generic message)
178 # - entry is undef if tag must not exist (same as 'not defined $val' in code)
179 1 my %validValue = (
180 JPEG => {
181 IFD0 => {
182 0x100 => undef, # ImageWidth
183 0x101 => undef, # ImageLength
184 0x102 => undef, # BitsPerSample
185 0x103 => undef, # Compression
186 0x106 => undef, # PhotometricInterpretation
187 0x111 => undef, # StripOffsets
188 0x115 => undef, # SamplesPerPixel
189 0x116 => undef, # RowsPerStrip
190 0x117 => undef, # StripByteCounts
191 # (optional as of 3.0) 0x11a => 'defined $val', # XResolution
192 # (optional as of 3.0) 0x11b => 'defined $val', # YResolution
193 0x11c => undef, # PlanarConfiguration
194 # (optional as of 3.0) 0x128 => '$val =~ /^[123]$/', # ResolutionUnit
195 0x201 => undef, # JPEGInterchangeFormat
196 0x202 => undef, # JPEGInterchangeFormatLength
197 0x212 => undef, # YCbCrSubSampling
198 0x213 => '$val =~ /^[12]$/', # YCbCrPositioning
199 },
200 IFD1 => {
201 0x100 => undef, # ImageWidth
202 0x101 => undef, # ImageLength
203 0x102 => undef, # BitsPerSample
204 0x103 => '$val == 6', # Compression
205 0x106 => undef, # PhotometricInterpretation
206 0x111 => undef, # StripOffsets
207 0x115 => undef, # SamplesPerPixel
208 0x116 => undef, # RowsPerStrip
209 0x117 => undef, # StripByteCounts
210 0x11a => 'defined $val', # XResolution
211 0x11b => 'defined $val', # YResolution
212 0x11c => undef, # PlanarConfiguration
213 0x128 => '$val =~ /^[123]$/', # ResolutionUnit
214 0x201 => 'defined $val', # JPEGInterchangeFormat
215 0x202 => 'defined $val', # JPEGInterchangeFormatLength
216 0x212 => undef, # YCbCrSubSampling
217 },
218 ExifIFD => {
219 0x9000 => 'defined $val and $val =~ /^\d{4}$/', # ExifVersion
220 0x9101 => 'defined $val', # ComponentsConfiguration
221 # (optional as of 3.0) 0xa000 => 'defined $val', # FlashpixVersion
222 0xa001 => '$val == 1 or $val == 0xffff', # ColorSpace
223 0xa002 => 'defined $val', # PixelXDimension
224 0xa003 => 'defined $val', # PixelYDimension
225 },
226 GPS => {
227 0x00 => 'defined $val and $val =~ /^\d \d \d \d$/', # GPSVersionID
228 0x1b => 'not defined $val or $val =~ /^(GPS|CELLID|WLAN|MANUAL)$/', # GPSProcessingMethod
229 },
230 InteropIFD => { }, # (needed for ExifVersion check)
231 },
232 TIFF => {
233 IFD0 => {
234 0x100 => 'defined $val', # ImageWidth
235 0x101 => 'defined $val', # ImageLength
236 # (default is 1) 0x102 => 'defined $val', # BitsPerSample
237 0x103 => q{
238 not defined $val or $val =~ /^(1|5|6|32773)$/ or
239 ($val == 2 and (not defined $val{0x102} or $val{0x102} == 1));
240 }, # Compression
241 0x106 => '$val =~ /^[0123]$/', # PhotometricInterpretation
242 0x111 => 'defined $val', # StripOffsets
243 # SamplesPerPixel
244 0x115 => q{
245 my $pi = $val{0x106} || 0;
246 my $xtra = ($val{0x152} ? scalar(split ' ', $val{0x152}) : 0);
247 if ($pi == 2 or $pi == 6) {
248 return $val == 3 + $xtra;
249 } elsif ($pi == 5) {
250 return $val == 4 + $xtra;
251 } else {
252 return 1;
253 }
254 },
255 0x116 => 'defined $val', # RowsPerStrip
256 0x117 => 'defined $val', # StripByteCounts
257 0x11a => 'defined $val', # XResolution
258 0x11b => 'defined $val', # YResolution
259 0x128 => 'not defined $val or $val =~ /^[123]$/', # ResolutionUnit
260 # ColorMap (must be palette image with correct number of colors)
261 0x140 => q{
262 return '' if defined $val{0x106} and $val{0x106} == 3 xor defined $val;
263 return 1 if not defined $val or length($val) == 6 * 2 ** ($val{0x102} || 0);
264 return 'Invalid count for';
265 },
266 0x201 => undef, # JPEGInterchangeFormat
267 0x202 => undef, # JPEGInterchangeFormatLength
268 },
269 ExifIFD => {
270 0x9000 => 'defined $val', # ExifVersion
271 0x9101 => undef, # ComponentsConfiguration
272 0x9102 => undef, # CompressedBitsPerPixel
273 0xa000 => 'defined $val', # FlashpixVersion
274 0xa001 => '$val == 1 or $val == 0xffff', # ColorSpace
275 0xa002 => undef, # PixelXDimension
276 0xa003 => undef, # PixelYDimension
277 },
278 InteropIFD => {
279 0x0001 => undef, # InteropIndex
280 },
281 GPS => {
282 0x00 => 'defined $val and $val =~ /^\d \d \d \d$/', # GPSVersionID
283 0x1b => '$val =~ /^(GPS|CELLID|WLAN|MANUAL)$/', # GPSProcessingMethod
284 },
285 },
286 );
287  
288 # validity ranges for constrained date/time fields
289 1 my @validDateField = (
290 [ 'Month', 1, 12 ],
291 [ 'Day', 1, 31 ],
292 [ 'Hour', 0, 23 ],
293 [ 'Minutes', 0, 59 ],
294 [ 'Seconds', 0, 59 ],
295 [ 'TZhr', 0, 14 ],
296 [ 'TZmin', 0, 59 ],
297 );
298  
299 # "Validate" tag information
300 my %validateInfo = (
301 Groups => { 0 => 'ExifTool', 1 => 'ExifTool', 2 => 'ExifTool' },
302 Notes => q{
303 generated only if specifically requested. Requesting this tag automatically
304 enables the API L<Validate|../ExifTool.html#Validate> option, imposing
305 additional validation checks when extracting metadata. Returns the number
306 of errors, warnings and minor warnings encountered. Note that the Validate
307 feature focuses mainly on validation of EXIF/TIFF metadata
308 },
309 PrintConv => {
310 '0 0 0' => 'OK',
311 0 ▶ OTHER => sub {
Subroutine __ANON__: not called CC=8 SCAR=42.8
312 0 my @val = split ' ', shift;
313 0 my @rtn;
314 0 ▶ push @rtn, sprintf('%d Error%s', $val[0], $val[0] == 1 ? '' : 's') if $val[0];
Branch: 2 branches
BranchTrueFalseTotal
if $val[0] 0 0 0
$val[0] == 1 ? : 0 0 0
315 0 ▶ push @rtn, sprintf('%d Warning%s', $val[1], $val[1] == 1 ? '' : 's') if $val[1];
Branch: 2 branches
BranchTrueFalseTotal
if $val[1] 0 0 0
$val[1] == 1 ? : 0 0 0
316 0 ▶ if ($val[2]) {
Branch: 1 branch
BranchTrueFalseTotal
if ($val[2]) 0 0 0
317 0 ▶ my $str = ($val[1] == $val[2] ? ($val[1] == 1 ? '' : 'all ') : "$val[2] ");
Branch: 2 branches
BranchTrueFalseTotal
$val[1] == $val[2] ? : 0 0 0
$val[1] == 1 ? : 0 0 0
318 0 $rtn[-1] .= " (${str}minor)";
319 }
320 0 return join(' and ', @rtn);
321 },
322 },
323 1 Hidden => 0,
324 );
325  
326 # add "Validate" tag to Extra table
327 1 AddTagToTable(\%Image::ExifTool::Extra, Validate => \%validateInfo, 1);
328  
329 #------------------------------------------------------------------------------
330 # Validate the raw value of a tag
331 # Inputs: 0) ExifTool ref, 1) tag key, 2) raw tag value
332 # Returns: nothing, but issues a minor Warning if a problem was detected
333 sub ValidateRaw($$$)
334 213 ▶{
Subroutine ValidateRaw: called CC=15 SCAR=33.0
Pod undocumented
335 213 my ($self, $tag, $val) = @_;
336 213 my $tagInfo = $$self{TAG_INFO}{$tag};
337 213 my $wrn;
338  
339 # evaluate Validate code if specified
340 213 ▶ if ($$tagInfo{Validate}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagInfo->{"Validate"}) 3 210 213
341 3 local $SIG{'__WARN__'} = \&Image::ExifTool::SetWarning;
342 3 undef $Image::ExifTool::evalWarning;
343 #### eval Validate ($self, $val, $tagInfo)
344 3 my $wrn = eval $$tagInfo{Validate};
345 3 ▶ my $err = $Image::ExifTool::evalWarning || $@;
Condition33%1/3
$Image::ExifTool::evalWarning || $@
l!l&&r!l&&!r
003
MC/DC0%0/2
$Image::ExifTool::evalWarning || $@
$Image::ExifTool::evalWarning $@
Truth table33%1/3
A || B
A= $Image::ExifTool::evalWarningB= $@
ABresult
1X1
011
000
346 3 ▶ if ($wrn or $err) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wrn or $err) 0 3 3
Condition33%1/3
$wrn or $err
l!l&&r!l&&!r
003
MC/DC0%0/2
$wrn or $err
$wrn $err
Truth table33%1/3
A or B
A= $wrnB= $err
ABresult
1X1
011
000
347 0 my $name = $$tagInfo{Table}{GROUPS}{0} . ':' . Image::ExifTool::GetTagName($tag);
348 0 ▶ $self->Warn("Validate $name: $err", 1) if $err;
Branch: 1 branch
BranchTrueFalseTotal
if $err 0 0 0
349 0 ▶ $self->Warn("$wrn for $name", 1) if $wrn;
Branch: 1 branch
BranchTrueFalseTotal
if $wrn 0 0 0
350 }
351 }
352 # check for unknown values in PrintConv lookup for all standard EXIF tags
353 213 ▶ if (ref $$tagInfo{PrintConv} eq 'HASH' and ($$tagInfo{Table}{SHORT_NAME} eq 'GPS::Main' or
Branch: 1 branch
BranchTrueFalseTotal
if (ref $tagInfo->{"PrintConv"} eq "HASH" and $tagInfo->{"Table"}{"SHORT_NAME"} eq "GPS::Main" || $tagInfo->{"Table"} eq \%Image::ExifTool::Exif::Main && $Image::ExifTool::Validate::exifSpec{$tagInfo->{"TagID"}}) 18 195 213
Condition88%8/9
ref $tagInfo->{"PrintConv"} eq "HASH" and $tagInfo->{"Table"}{"SHORT_NAME"} eq "GPS::Main" || $tagInfo->{"Table"} eq \%Image::ExifTool::Exif::Main && $Image::ExifTool::Validate::exifSpec{$tagInfo->{"TagID"}}
!ll&&!rl&&r
1435218
$tagInfo->{"Table"}{"SHORT_NAME"} eq "GPS::Main" or $tagInfo->{"Table"} eq \%Image::ExifTool::Exif::Main and $Image::ExifTool::Validate::exifSpec{$tagInfo->{"TagID"}}
l!l&&r!l&&!r
01852
$tagInfo->{"Table"} eq \%Image::ExifTool::Exif::Main and $Image::ExifTool::Validate::exifSpec{$tagInfo->{"TagID"}}
!ll&&!rl&&r
51118
MC/DC75%3/4
ref $tagInfo->{"PrintConv"} eq "HASH" and $tagInfo->{"Table"}{"SHORT_NAME"} eq "GPS::Main" || $tagInfo->{"Table"} eq \%Image::ExifTool::Exif::Main && $Image::ExifTool::Validate::exifSpec{$tagInfo->{"TagID"}}
ref $tagInfo->{"PrintConv"} eq "HASH" $tagInfo->{"Table"}{"SHORT_NAME"} eq "GPS::Main" $tagInfo->{"Table"} eq \%Image::ExifTool::Exif::Main $Image::ExifTool::Validate::exifSpec{$tagInfo->{"TagID"}}
Truth table80%4/5
A and B or C and D
A= ref $tagInfo->{"PrintConv"} eq "HASH"B= $tagInfo->{"Table"}{"SHORT_NAME"} eq "GPS::Main"C= $tagInfo->{"Table"} eq \%Image::ExifTool::Exif::MainD= $Image::ExifTool::Validate::exifSpec{$tagInfo->{"TagID"}}
ABCDresult
0XXX0
100X0
10100
11XX1
10111
354 ($$tagInfo{Table} eq \%Image::ExifTool::Exif::Main and $exifSpec{$$tagInfo{TagID}})))
355 {
356 18 my $prt = $self->GetValue($tag, 'PrintConv');
357 18 ▶ $wrn = 'Unknown value for' if $prt and $prt =~ /^Unknown \(/;
Branch: 1 branch
BranchTrueFalseTotal
if $prt and $prt =~ /^Unknown \(/ 0 18 18
Condition33%1/3
$prt and $prt =~ /^Unknown \(/
!ll&&!rl&&r
0180
MC/DC0%0/2
$prt and $prt =~ /^Unknown \(/
$prt $prt =~ /^Unknown \(/
Truth table33%1/3
A and B
A= $prtB= $prt =~ /^Unknown \(/
ABresult
0X0
100
111
358 }
359 213 ▶ $wrn = 'Undefined value for' if $val eq 'undef';
Branch: 1 branch
BranchTrueFalseTotal
if $val eq "undef" 0 213 213
360 213 ▶ if ($wrn) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wrn) 0 213 213
361 0 my $name = $$self{DIR_NAME} . ':' . Image::ExifTool::GetTagName($tag);
362 0 $self->Warn("$wrn $name", 1);
363 }
364 }
365  
366 #------------------------------------------------------------------------------
367 # Validate raw EXIF date/time value
368 # Inputs: 0) date/time value
369 # Returns: error string
370 sub ValidateExifDate($)
371 3 ▶{
Subroutine ValidateExifDate: called CC=9 SCAR=29.0
Pod undocumented
372 3 my $val = shift;
373 3 ▶ if ($val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})$/) {
Branch: 2 branches
BranchTrueFalseTotal
if ($val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})$/) { } 3 0 3
elsif ($val ne ' : : : : ' and $val ne ' ') { } 0 0 0
374 3 my @a = ($1,$2,$3,$4,$5);
375 3 my ($i, @bad);
376 3 ▶ for ($i=0; $i<@a; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @a) 15 3 18
377 15 ▶ next if $a[$i] eq ' ' or ($a[$i] >= $validDateField[$i][1] and $a[$i] <= $validDateField[$i][2]);
Branch: 1 branch
BranchTrueFalseTotal
if $a[$i] eq " " or $a[$i] >= $validDateField[$i][1] and $a[$i] <= $validDateField[$i][2] 15 0 15
Condition33%2/6
$a[$i] eq " " or $a[$i] >= $validDateField[$i][1] and $a[$i] <= $validDateField[$i][2]
l!l&&r!l&&!r
0150
$a[$i] >= $validDateField[$i][1] and $a[$i] <= $validDateField[$i][2]
!ll&&!rl&&r
0015
MC/DC0%0/3
$a[$i] eq " " or $a[$i] >= $validDateField[$i][1] and $a[$i] <= $validDateField[$i][2]
$a[$i] eq " " $a[$i] >= $validDateField[$i][1] $a[$i] <= $validDateField[$i][2]
Truth table25%1/4
A or B and C
A= $a[$i] eq " "B= $a[$i] >= $validDateField[$i][1]C= $a[$i] <= $validDateField[$i][2]
ABCresult
1XX1
0111
00X0
0100
378 0 push @bad, $validDateField[$i][0];
379 }
380 3 ▶ return join('+', @bad) . ' out of range' if @bad;
Branch: 1 branch
BranchTrueFalseTotal
if @bad 0 3 3
381 # the EXIF specification allows blank fields or an entire blank value
382 ▶ } elsif ($val ne ' : : : : ' and $val ne ' ') {
Condition0%0/3
$val ne " : : : : " and $val ne " "
!ll&&!rl&&r
000
MC/DC0%0/2
$val ne " : : : : " and $val ne " "
$val ne " : : : : " $val ne " "
Truth table0%0/3
A and B
A= $val ne " : : : : "B= $val ne " "
ABresult
0X0
100
111
383 0 return 'Invalid date/time format';
384 }
385 3 return undef; # OK!
386 }
387  
388 #------------------------------------------------------------------------------
389 # Validate EXIF-reformatted XMP date/time value
390 # Inputs: 0) date/time value
391 # Returns: error string
392 sub ValidateXMPDate($)
393 0 ▶{
Subroutine ValidateXMPDate: not called CC=13 SCAR=52.0
Pod undocumented
394 0 my $val = shift;
395 0 ▶ if ($val =~ /^\d{4}$/ or
Branch: 1 branch
BranchTrueFalseTotal
if ($val =~ /^\d{4}$/ or $val =~ /^\d{4}:(\d{2})$/ or $val =~ /^\d{4}:(\d{2}):(\d{2})$/ or $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2})()(Z|[-+](\d{2}):(\d{2}))?$/ or $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})(Z|[-+](\d{2}):(\d{2}))?$/ or $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})\.?\d*(Z|[-+](\d{2}):(\d{2}))?$/) { } 0 0 0
Condition0%0/15
$val =~ /^\d{4}$/ or $val =~ /^\d{4}:(\d{2})$/ or $val =~ /^\d{4}:(\d{2}):(\d{2})$/ or $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2})()(Z|[-+](\d{2}):(\d{2}))?$/ or $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})(Z|[-+](\d{2}):(\d{2}))?$/ or $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})\.?\d*(Z|[-+](\d{2}):(\d{2}))?$/
l!l&&r!l&&!r
000
$val =~ /^\d{4}$/ or $val =~ /^\d{4}:(\d{2})$/ or $val =~ /^\d{4}:(\d{2}):(\d{2})$/ or $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2})()(Z|[-+](\d{2}):(\d{2}))?$/ or $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})(Z|[-+](\d{2}):(\d{2}))?$/
l!l&&r!l&&!r
000
$val =~ /^\d{4}$/ or $val =~ /^\d{4}:(\d{2})$/ or $val =~ /^\d{4}:(\d{2}):(\d{2})$/ or $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2})()(Z|[-+](\d{2}):(\d{2}))?$/
l!l&&r!l&&!r
000
$val =~ /^\d{4}$/ or $val =~ /^\d{4}:(\d{2})$/ or $val =~ /^\d{4}:(\d{2}):(\d{2})$/
l!l&&r!l&&!r
000
$val =~ /^\d{4}$/ or $val =~ /^\d{4}:(\d{2})$/
l!l&&r!l&&!r
000
MC/DC0%0/6
$val =~ /^\d{4}$/ or $val =~ /^\d{4}:(\d{2})$/ or $val =~ /^\d{4}:(\d{2}):(\d{2})$/ or $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2})()(Z|[-+](\d{2}):(\d{2}))?$/ or $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})(Z|[-+](\d{2}):(\d{2}))?$/ or $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})\.?\d*(Z|[-+](\d{2}):(\d{2}))?$/
$val =~ /^\d{4}$/ $val =~ /^\d{4}:(\d{2})$/ $val =~ /^\d{4}:(\d{2}):(\d{2})$/ $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2})()(Z|[-+](\d{2}):(\d{2}))?$/ $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})(Z|[-+](\d{2}):(\d{2}))?$/ $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})\.?\d*(Z|[-+](\d{2}):(\d{2}))?$/
Truth table0%0/7
A or B or C or D or E or F
A= $val =~ /^\d{4}$/B= $val =~ /^\d{4}:(\d{2})$/C= $val =~ /^\d{4}:(\d{2}):(\d{2})$/D= $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2})()(Z|[-+](\d{2}):(\d{2}))?$/E= $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})(Z|[-+](\d{2}):(\d{2}))?$/F= $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})\.?\d*(Z|[-+](\d{2}):(\d{2}))?$/
ABCDEFresult
1XXXXX1
01XXXX1
001XXX1
0001XX1
00001X1
0000011
0000000
396 $val =~ /^\d{4}:(\d{2})$/ or
397 $val =~ /^\d{4}:(\d{2}):(\d{2})$/ or
398 $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2})()(Z|[-+](\d{2}):(\d{2}))?$/ or
399 $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})(Z|[-+](\d{2}):(\d{2}))?$/ or
400 $val =~ /^\d{4}:(\d{2}):(\d{2}) (\d{2}):(\d{2}):(\d{2})\.?\d*(Z|[-+](\d{2}):(\d{2}))?$/)
401 {
402 0 my @a = ($1,$2,$3,$4,$5,$7,$8);
403 0 my ($i, @bad);
404 0 ▶ for ($i=0; $i<@a; ++$i) {
Branch: 1 branch
BranchTrueFalseTotal
if ($i < @a) 0 0 0
405 0 ▶ last unless defined $a[$i];
Branch: 1 branch
BranchTrueFalseTotal
unless defined $a[$i] 0 0 0
406 0 ▶ next if $a[$i] eq '' or ($a[$i] >= $validDateField[$i][1] and $a[$i] <= $validDateField[$i][2]);
Branch: 1 branch
BranchTrueFalseTotal
if $a[$i] eq "" or $a[$i] >= $validDateField[$i][1] and $a[$i] <= $validDateField[$i][2] 0 0 0
Condition0%0/6
$a[$i] eq "" or $a[$i] >= $validDateField[$i][1] and $a[$i] <= $validDateField[$i][2]
l!l&&r!l&&!r
000
$a[$i] >= $validDateField[$i][1] and $a[$i] <= $validDateField[$i][2]
!ll&&!rl&&r
000
MC/DC0%0/3
$a[$i] eq "" or $a[$i] >= $validDateField[$i][1] and $a[$i] <= $validDateField[$i][2]
$a[$i] eq "" $a[$i] >= $validDateField[$i][1] $a[$i] <= $validDateField[$i][2]
Truth table0%0/4
A or B and C
A= $a[$i] eq ""B= $a[$i] >= $validDateField[$i][1]C= $a[$i] <= $validDateField[$i][2]
ABCresult
1XX1
0111
00X0
0100
407 0 push @bad, $validDateField[$i][0];
408 }
409 0 ▶ return join('+', @bad) . ' out of range' if @bad;
Branch: 1 branch
BranchTrueFalseTotal
if @bad 0 0 0
410 } else {
411 0 return 'Invalid date/time format';
412 }
413 0 return undef; # OK!
414 }
415  
416 #------------------------------------------------------------------------------
417 # Validate EXIF tag
418 # Inputs: 0) ExifTool ref, 1) tag table ref, 2) tag ID, 3) tagInfo ref,
419 # 4) previous tag ID, 5) IFD name, 6) number of values, 7) value format string
420 # Returns: Nothing, but sets Warning tags if any problems are found
421 sub ValidateExif($$$$$$$$)
422 63 ▶{
Subroutine ValidateExif: called CC=56 SCAR=60.5
Pod undocumented
423 63 my ($et, $tagTablePtr, $tag, $tagInfo, $lastTag, $ifd, $count, $formatStr) = @_;
424  
425 63 ▶ $et->Warn("Entries in $ifd are out of order") if $tag <= $lastTag;
Branch: 1 branch
BranchTrueFalseTotal
if $tag <= $lastTag 0 63 63
426  
427 # (get tagInfo for unknown tags if Unknown option not used)
428 63 ▶ if (not defined $tagInfo and $$tagTablePtr{$tag} and ref $$tagTablePtr{$tag} eq 'HASH') {
Branch: 1 branch
BranchTrueFalseTotal
if (not defined $tagInfo and $tagTablePtr->{$tag} and ref $tagTablePtr->{$tag} eq "HASH") 0 63 63
Condition50%3/6
not defined $tagInfo and $tagTablePtr->{$tag} and ref $tagTablePtr->{$tag} eq "HASH"
!ll&&!rl&&r
6300
not defined $tagInfo and $tagTablePtr->{$tag}
!ll&&!rl&&r
6120
MC/DC0%0/3
not defined $tagInfo and $tagTablePtr->{$tag} and ref $tagTablePtr->{$tag} eq "HASH"
not defined $tagInfo $tagTablePtr->{$tag} ref $tagTablePtr->{$tag} eq "HASH"
Truth table50%2/4
not(A) and B and C
A= not defined $tagInfoB= $tagTablePtr->{$tag}C= ref $tagTablePtr->{$tag} eq "HASH"
ABCresult
0XX0
10X0
1100
1111
429 0 $tagInfo = $$tagTablePtr{$tag};
430 }
431 63 ▶ if (defined $tagInfo) {
Branch: 2 branches
BranchTrueFalseTotal
if (defined $tagInfo) { } 61 2 63
elsif (not $otherSpec{$et->{'FileType'}} && ($otherSpec{$et->{'FileType'}}{$tag} || $otherSpec{$et->{'FileType'}}{'All'})) { } 0 2 2
432 61 ▶ my $ti = $tagInfo || $$tagTablePtr{$tag};
Condition66%2/3
$tagInfo || $tagTablePtr->{$tag}
l!l&&r!l&&!r
6010
MC/DC0%0/2
$tagInfo || $tagTablePtr->{$tag}
$tagInfo $tagTablePtr->{$tag}
Truth table66%2/3
A || B
A= $tagInfoB= $tagTablePtr->{$tag}
ABresult
1X1
011
000
433 61 ▶ $ti = $$ti[-1] if ref $ti eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $ti eq "ARRAY" 1 60 61
434 61 ▶ my $stdFmt = $stdFormat{$ifd} || $stdFormat{IFD};
Condition66%2/3
$stdFormat{$ifd} || $stdFormat{'IFD'}
l!l&&r!l&&!r
30310
MC/DC0%0/2
$stdFormat{$ifd} || $stdFormat{'IFD'}
$stdFormat{$ifd} $stdFormat{'IFD'}
Truth table66%2/3
A || B
A= $stdFormat{$ifd}B= $stdFormat{'IFD'}
ABresult
1X1
011
000
435 61 ▶ if (defined $$stdFmt{All} or ($tagTablePtr eq \%Image::ExifTool::Exif::Main and
Branch: 3 branches
BranchTrueFalseTotal
if (defined $stdFmt->{'All'} or $tagTablePtr eq \%Image::ExifTool::Exif::Main and $Image::ExifTool::Validate::exifSpec{$tag} || $stdFmt->{$tag} || $tag >= 50706 && $tag <= 52552 && !defined($stdFmt->{$tag}) or $tagTablePtr->{'SHORT_NAME'} eq 'GPS::Main') { } 59 2 61
elsif ($stdFormatAnyIFD{$tag}) { } 0 2 2
elsif (not $otherSpec{$et->{'FileType'}} && ($otherSpec{$et->{'FileType'}}{$tag} || $otherSpec{$et->{'FileType'}}{'All'})) { } 0 2 2
Condition71%15/21
defined $stdFmt->{"All"} or $tagTablePtr eq \%Image::ExifTool::Exif::Main and $Image::ExifTool::Validate::exifSpec{$tag} || $stdFmt->{$tag} || $tag >= 50706 && $tag <= 52552 && !defined($stdFmt->{$tag}) or $tagTablePtr->{"SHORT_NAME"} eq "GPS::Main"
l!l&&r!l&&!r
5902
defined $stdFmt->{"All"} or $tagTablePtr eq \%Image::ExifTool::Exif::Main and $Image::ExifTool::Validate::exifSpec{$tag} || $stdFmt->{$tag} || $tag >= 50706 && $tag <= 52552 && !defined($stdFmt->{$tag})
l!l&&r!l&&!r
0592
$tagTablePtr eq \%Image::ExifTool::Exif::Main and $Image::ExifTool::Validate::exifSpec{$tag} || $stdFmt->{$tag} || $tag >= 50706 && $tag <= 52552 && !defined($stdFmt->{$tag})
!ll&&!rl&&r
0259
$Image::ExifTool::Validate::exifSpec{$tag} or $stdFmt->{$tag} or $tag >= 50706 and $tag <= 52552 and not defined $stdFmt->{$tag}
l!l&&r!l&&!r
5902
$Image::ExifTool::Validate::exifSpec{$tag} or $stdFmt->{$tag}
l!l&&r!l&&!r
5812
$tag >= 50706 and $tag <= 52552 and not defined $stdFmt->{$tag}
!ll&&!rl&&r
110
$tag >= 50706 and $tag <= 52552
!ll&&!rl&&r
101
MC/DC25%2/8
defined $stdFmt->{"All"} or $tagTablePtr eq \%Image::ExifTool::Exif::Main and $Image::ExifTool::Validate::exifSpec{$tag} || $stdFmt->{$tag} || $tag >= 50706 && $tag <= 52552 && !defined($stdFmt->{$tag}) or $tagTablePtr->{"SHORT_NAME"} eq "GPS::Main"
defined $stdFmt->{"All"} $tagTablePtr eq \%Image::ExifTool::Exif::Main $Image::ExifTool::Validate::exifSpec{$tag} $stdFmt->{$tag} $tag >= 50706 $tag <= 52552 not defined $stdFmt->{$tag} $tagTablePtr->{"SHORT_NAME"} eq "GPS::Main"
Truth table33%4/12
A or B and C or D or E and F and not(G) or H
A= defined $stdFmt->{"All"}B= $tagTablePtr eq \%Image::ExifTool::Exif::MainC= $Image::ExifTool::Validate::exifSpec{$tag}D= $stdFmt->{$tag}E= $tag >= 50706F= $tag <= 52552G= not defined $stdFmt->{$tag}H= $tagTablePtr->{"SHORT_NAME"} eq "GPS::Main"
ABCDEFGHresult
1XXXXXXX1
011XXXXX1
0101XXXX1
0100111X1
00XXXXX11
01000XX11
010010X11
010011011
00XXXXX00
01000XX00
010010X00
010011000
436 ($exifSpec{$tag} or $$stdFmt{$tag} or
437 ($tag >= 0xc612 and $tag <= 0xcd48 and not defined $$stdFmt{$tag}))) or # (DNG tags)
438 $$tagTablePtr{SHORT_NAME} eq 'GPS::Main')
439 {
440 59 ▶ my $wgp = $$ti{WriteGroup} || $$tagTablePtr{WRITE_GROUP};
Condition66%2/3
$ti->{'WriteGroup'} || $tagTablePtr->{'WRITE_GROUP'}
l!l&&r!l&&!r
28310
MC/DC0%0/2
$ti->{'WriteGroup'} || $tagTablePtr->{'WRITE_GROUP'}
$ti->{'WriteGroup'} $tagTablePtr->{'WRITE_GROUP'}
Truth table66%2/3
A || B
A= $ti->{'WriteGroup'}B= $tagTablePtr->{'WRITE_GROUP'}
ABresult
1X1
011
000
441 59 ▶ if ($wgp and $wgp ne $ifd and $wgp ne 'All' and not $$ti{OffsetPair} and
Branch: 1 branch
BranchTrueFalseTotal
if ($wgp and $wgp ne $ifd and $wgp ne "All" and not $ti->{"OffsetPair"} and $ifd =~ /^(Sub|Profile)?IFD\d*$/ ^^ $wgp =~ /^(Sub)?IFD\d*$/ and $ti->{"Writable"} || $ti->{"WriteGroup"} and not $ifd =~ /^SRF\d+$/) 0 59 59
Condition48%12/25
$wgp and $wgp ne $ifd and $wgp ne "All" and not $ti->{"OffsetPair"} and $ifd =~ /^(Sub|Profile)?IFD\d*$/ ^^ $wgp =~ /^(Sub)?IFD\d*$/ and $ti->{"Writable"} || $ti->{"WriteGroup"} and not $ifd =~ /^SRF\d+$/
!ll&&!rl&&r
5900
$wgp and $wgp ne $ifd and $wgp ne "All" and not $ti->{"OffsetPair"} and $ifd =~ /^(Sub|Profile)?IFD\d*$/ ^^ $wgp =~ /^(Sub)?IFD\d*$/ and $ti->{"Writable"} || $ti->{"WriteGroup"}
!ll&&!rl&&r
5900
$wgp and $wgp ne $ifd and $wgp ne "All" and not $ti->{"OffsetPair"} and $ifd =~ /^(Sub|Profile)?IFD\d*$/ ^^ $wgp =~ /^(Sub)?IFD\d*$/
!ll&&!rl&&r
5090
$wgp and $wgp ne $ifd and $wgp ne "All" and not $ti->{"OffsetPair"}
!ll&&!rl&&r
4649
$wgp and $wgp ne $ifd and $wgp ne "All"
!ll&&!rl&&r
46013
$wgp and $wgp ne $ifd
!ll&&!rl&&r
04613
$ifd =~ /^(Sub|Profile)?IFD\d*$/ xor $wgp =~ /^(Sub)?IFD\d*$/
l&&rl&&!r!l&&r!l&&!r
9000
$ti->{"Writable"} or $ti->{"WriteGroup"}
l!l&&r!l&&!r
000
MC/DC0%0/9
$wgp and $wgp ne $ifd and $wgp ne "All" and not $ti->{"OffsetPair"} and $ifd =~ /^(Sub|Profile)?IFD\d*$/ ^^ $wgp =~ /^(Sub)?IFD\d*$/ and $ti->{"Writable"} || $ti->{"WriteGroup"} and not $ifd =~ /^SRF\d+$/
$wgp $wgp ne $ifd $wgp ne "All" not $ti->{"OffsetPair"} $ifd =~ /^(Sub|Profile)?IFD\d*$/ $wgp =~ /^(Sub)?IFD\d*$/ $ti->{"Writable"} $ti->{"WriteGroup"} not $ifd =~ /^SRF\d+$/
Truth table18%3/16
A and B and C and not(D) and E xor F and G or H and not(I)
A= $wgpB= $wgp ne $ifdC= $wgp ne "All"D= not $ti->{"OffsetPair"}E= $ifd =~ /^(Sub|Profile)?IFD\d*$/F= $wgp =~ /^(Sub)?IFD\d*$/G= $ti->{"Writable"}H= $ti->{"WriteGroup"}I= not $ifd =~ /^SRF\d+$/
ABCDEFGHIresult
0XXXXXXXX0
10XXXXXXX0
110XXXXXX0
1110XXXXX0
111111XXX0
111100XXX0
11111000X0
11110100X0
1111101X00
1111100100
1111011X00
1111010100
1111101X11
1111100111
1111011X11
1111010111
442 ($ifd =~ /^(Sub|Profile)?IFD\d*$/ xor $wgp =~ /^(Sub)?IFD\d*$/) and
443 ($$ti{Writable} or $$ti{WriteGroup}) and $ifd !~ /^SRF\d+$/)
444 {
445 0 $et->Warn(sprintf('Wrong IFD for 0x%.4x %s (should be %s not %s)', $tag, $$ti{Name}, $wgp, $ifd));
446 }
447 59 ▶ my $fmt = $$stdFmt{$tag} || $$ti{Writable};
Condition100%3/3
$stdFmt->{$tag} || $ti->{'Writable'}
l!l&&r!l&&!r
19382
MC/DC100%2/2
$stdFmt->{$tag} || $ti->{'Writable'}
$stdFmt->{$tag} $ti->{'Writable'}
Truth table100%3/3
A || B
A= $stdFmt->{$tag}B= $ti->{'Writable'}
ABresult
1X1
011
000
448 59 ▶ if ($fmt and $formatStr !~ /^$fmt$/ and (not $tagInfo or
Branch: 1 branch
BranchTrueFalseTotal
if ($fmt and not $formatStr =~ /^$fmt$/ and !($tagInfo && $tagInfo->{"IsOffset"}) || $Image::ExifTool::Exif::intFormat{$formatStr}) 0 59 59
Condition25%3/12
$fmt and not $formatStr =~ /^$fmt$/ and !($tagInfo && $tagInfo->{"IsOffset"}) || $Image::ExifTool::Exif::intFormat{$formatStr}
!ll&&!rl&&r
5900
$fmt and not $formatStr =~ /^$fmt$/
!ll&&!rl&&r
2570
not $tagInfo && $tagInfo->{"IsOffset"} or $Image::ExifTool::Exif::intFormat{$formatStr}
l!l&&r!l&&!r
000
$tagInfo && $tagInfo->{'IsOffset'}
!ll&&!rl&&r
000
MC/DC0%0/5
$fmt and not $formatStr =~ /^$fmt$/ and !($tagInfo && $tagInfo->{"IsOffset"}) || $Image::ExifTool::Exif::intFormat{$formatStr}
$fmt not $formatStr =~ /^$fmt$/ $tagInfo $tagInfo->{'IsOffset'} $Image::ExifTool::Exif::intFormat{$formatStr}
Truth table33%2/6
A and not(B) and not(C && D) or E
A= $fmtB= not $formatStr =~ /^$fmt$/C= $tagInfoD= $tagInfo->{'IsOffset'}E= $Image::ExifTool::Exif::intFormat{$formatStr}
ABCDEresult
0XXXX0
10XXX0
111100
110XX1
1110X1
111111
449 not $$tagInfo{IsOffset} or $Image::ExifTool::Exif::intFormat{$formatStr}))
450 {
451 0 $et->Warn(sprintf('Non-standard format (%s) for %s 0x%.4x %s', $formatStr, $ifd, $tag, $$ti{Name}))
452 }
453 } elsif ($stdFormatAnyIFD{$tag}) {
454 0 ▶ if ($$ti{Writable} || $$ti{WriteGroup}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($ti->{"Writable"} or $ti->{"WriteGroup"}) 0 0 0
Condition0%0/3
$ti->{"Writable"} or $ti->{"WriteGroup"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$ti->{"Writable"} or $ti->{"WriteGroup"}
$ti->{"Writable"} $ti->{"WriteGroup"}
Truth table0%0/3
A or B
A= $ti->{"Writable"}B= $ti->{"WriteGroup"}
ABresult
1X1
011
000
455 0 ▶ my $wgp = $$ti{WriteGroup} || $$tagTablePtr{WRITE_GROUP};
Condition0%0/3
$ti->{'WriteGroup'} || $tagTablePtr->{'WRITE_GROUP'}
l!l&&r!l&&!r
000
MC/DC0%0/2
$ti->{'WriteGroup'} || $tagTablePtr->{'WRITE_GROUP'}
$ti->{'WriteGroup'} $tagTablePtr->{'WRITE_GROUP'}
Truth table0%0/3
A || B
A= $ti->{'WriteGroup'}B= $tagTablePtr->{'WRITE_GROUP'}
ABresult
1X1
011
000
456 0 ▶ if ($wgp and $wgp ne $ifd) {
Branch: 1 branch
BranchTrueFalseTotal
if ($wgp and $wgp ne $ifd) 0 0 0
Condition0%0/3
$wgp and $wgp ne $ifd
!ll&&!rl&&r
000
MC/DC0%0/2
$wgp and $wgp ne $ifd
$wgp $wgp ne $ifd
Truth table0%0/3
A and B
A= $wgpB= $wgp ne $ifd
ABresult
0X0
100
111
457 0 $et->Warn(sprintf('Wrong IFD for 0x%.4x %s (should be %s not %s)', $tag, $$ti{Name}, $wgp, $ifd));
458 }
459 }
460 ▶ } elsif (not $otherSpec{$$et{FileType}} or
Condition33%2/6
$otherSpec{$et->{'FileType'}} && ($otherSpec{$et->{'FileType'}}{$tag} || $otherSpec{$et->{'FileType'}}{'All'})
!ll&&!rl&&r
002
$otherSpec{$et->{"FileType"}}{$tag} or $otherSpec{$et->{"FileType"}}{"All"}
l!l&&r!l&&!r
200
MC/DC0%0/3
$otherSpec{$et->{'FileType'}} && ($otherSpec{$et->{'FileType'}}{$tag} || $otherSpec{$et->{'FileType'}}{'All'})
$otherSpec{$et->{'FileType'}} $otherSpec{$et->{"FileType"}}{$tag} $otherSpec{$et->{"FileType"}}{"All"}
Truth table25%1/4
A && B or C
A= $otherSpec{$et->{'FileType'}}B= $otherSpec{$et->{"FileType"}}{$tag}C= $otherSpec{$et->{"FileType"}}{"All"}
ABCresult
0XX0
1000
11X1
1011
461 (not $otherSpec{$$et{FileType}}{$tag} and not $otherSpec{$$et{FileType}}{All}))
462 {
463 0 ▶ if ($tagTablePtr eq \%Image::ExifTool::Exif::Main or $$ti{Unknown}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tagTablePtr eq \%Image::ExifTool::Exif::Main or $ti->{"Unknown"}) 0 0 0
Condition0%0/3
$tagTablePtr eq \%Image::ExifTool::Exif::Main or $ti->{"Unknown"}
l!l&&r!l&&!r
000
MC/DC0%0/2
$tagTablePtr eq \%Image::ExifTool::Exif::Main or $ti->{"Unknown"}
$tagTablePtr eq \%Image::ExifTool::Exif::Main $ti->{"Unknown"}
Truth table0%0/3
A or B
A= $tagTablePtr eq \%Image::ExifTool::Exif::MainB= $ti->{"Unknown"}
ABresult
1X1
011
000
464 0 ▶ $et->Warn(sprintf('Non-standard %s tag 0x%.4x %s', $ifd, $tag, $$ti{Name}), 1) unless $otherSpec{$ifd};
Branch: 1 branch
BranchTrueFalseTotal
unless $otherSpec{$ifd} 0 0 0
465 }
466 }
467 # change expected count from read Format to Writable size
468 61 my $tiCount = $$ti{Count};
469 61 ▶ if ($tiCount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tiCount) 4 57 61
470 4 ▶ if ($$ti{Format} and $$ti{Writable} and
Branch: 1 branch
BranchTrueFalseTotal
if ($ti->{"Format"} and $ti->{"Writable"} and $Image::ExifTool::Exif::formatNumber{$ti->{"Format"}} and $Image::ExifTool::Exif::formatNumber{$ti->{"Writable"}}) 1 3 4
Condition66%6/9
$ti->{"Format"} and $ti->{"Writable"} and $Image::ExifTool::Exif::formatNumber{$ti->{"Format"}} and $Image::ExifTool::Exif::formatNumber{$ti->{"Writable"}}
!ll&&!rl&&r
301
$ti->{"Format"} and $ti->{"Writable"} and $Image::ExifTool::Exif::formatNumber{$ti->{"Format"}}
!ll&&!rl&&r
301
$ti->{"Format"} and $ti->{"Writable"}
!ll&&!rl&&r
301
MC/DC25%1/4
$ti->{"Format"} and $ti->{"Writable"} and $Image::ExifTool::Exif::formatNumber{$ti->{"Format"}} and $Image::ExifTool::Exif::formatNumber{$ti->{"Writable"}}
$ti->{"Format"} $ti->{"Writable"} $Image::ExifTool::Exif::formatNumber{$ti->{"Format"}} $Image::ExifTool::Exif::formatNumber{$ti->{"Writable"}}
Truth table40%2/5
A and B and C and D
A= $ti->{"Format"}B= $ti->{"Writable"}C= $Image::ExifTool::Exif::formatNumber{$ti->{"Format"}}D= $Image::ExifTool::Exif::formatNumber{$ti->{"Writable"}}
ABCDresult
0XXX0
10XX0
110X0
11100
11111
471 $Image::ExifTool::Exif::formatNumber{$$ti{Format}} and
472 $Image::ExifTool::Exif::formatNumber{$$ti{Writable}})
473 {
474 1 my $s1 = $Image::ExifTool::Exif::formatSize[$Image::ExifTool::Exif::formatNumber{$$ti{Format}}];
475 1 my $s2 = $Image::ExifTool::Exif::formatSize[$Image::ExifTool::Exif::formatNumber{$$ti{Writable}}];
476 1 $tiCount = int($tiCount * $s1 / $s2);
477 }
478 4 ▶ if ($tiCount > 0 and $count != $tiCount) {
Branch: 1 branch
BranchTrueFalseTotal
if ($tiCount > 0 and $count != $tiCount) 0 4 4
Condition66%2/3
$tiCount > 0 and $count != $tiCount
!ll&&!rl&&r
310
MC/DC0%0/2
$tiCount > 0 and $count != $tiCount
$tiCount > 0 $count != $tiCount
Truth table66%2/3
A and B
A= $tiCount > 0B= $count != $tiCount
ABresult
0X0
100
111
479 0 $et->Warn(sprintf('Non-standard count (%d) for %s 0x%.4x %s', $count, $ifd, $tag, $$ti{Name}));
480 }
481 }
482 ▶ } elsif (not $otherSpec{$$et{FileType}} or
Condition33%2/6
$otherSpec{$et->{'FileType'}} && ($otherSpec{$et->{'FileType'}}{$tag} || $otherSpec{$et->{'FileType'}}{'All'})
!ll&&!rl&&r
002
$otherSpec{$et->{"FileType"}}{$tag} or $otherSpec{$et->{"FileType"}}{"All"}
l!l&&r!l&&!r
200
MC/DC0%0/3
$otherSpec{$et->{'FileType'}} && ($otherSpec{$et->{'FileType'}}{$tag} || $otherSpec{$et->{'FileType'}}{'All'})
$otherSpec{$et->{'FileType'}} $otherSpec{$et->{"FileType"}}{$tag} $otherSpec{$et->{"FileType"}}{"All"}
Truth table25%1/4
A && B or C
A= $otherSpec{$et->{'FileType'}}B= $otherSpec{$et->{"FileType"}}{$tag}C= $otherSpec{$et->{"FileType"}}{"All"}
ABCresult
0XX0
1000
11X1
1011
483 (not $otherSpec{$$et{FileType}}{$tag} and not $otherSpec{$$et{FileType}}{All}))
484 {
485 0 ▶ $et->Warn(sprintf('Unknown %s tag 0x%.4x', $ifd, $tag), 1) unless $otherSpec{$ifd};
Branch: 1 branch
BranchTrueFalseTotal
unless $otherSpec{$ifd} 0 0 0
486 }
487 }
488  
489 #------------------------------------------------------------------------------
490 # Validate image data offsets/sizes
491 # Inputs: 0) ExifTool ref, 1) offset info hash ref (arrays of tagInfo/value pairs, keyed by tagID)
492 # 2) directory name, 3) optional flag for minor warning
493 sub ValidateOffsetInfo($$$;$)
494 5 ▶{
Subroutine ValidateOffsetInfo: called CC=24 SCAR=39.3
Pod undocumented
495 5 local $_;
496 5 my ($et, $offsetInfo, $dirName, $minor) = @_;
497  
498 5 ▶ my $fileSize = $$et{VALUE}{FileSize} or return;
Branch: 1 branch
BranchTrueFalseTotal
my $fileSize = $et->{"VALUE"}{"FileSize"} or return 5 0 5
499  
500 # (don't test RWZ files and some other file types)
501 5 ▶ return if $$et{DontValidateImageData};
Branch: 1 branch
BranchTrueFalseTotal
if $et->{"DontValidateImageData"} 0 5 5
502 # (Minolta A200 uses wrong byte order for these)
503 5 ▶ return if $$et{TIFF_TYPE} eq 'MRW' and $dirName eq 'IFD0' and $$et{Model} =~ /^DiMAGE A200/;
Branch: 1 branch
BranchTrueFalseTotal
if $et->{"TIFF_TYPE"} eq "MRW" and $dirName eq "IFD0" and $et->{"Model"} =~ /^DiMAGE A200/ 0 5 5
Condition33%2/6
$et->{"TIFF_TYPE"} eq "MRW" and $dirName eq "IFD0" and $et->{"Model"} =~ /^DiMAGE A200/
!ll&&!rl&&r
500
$et->{"TIFF_TYPE"} eq "MRW" and $dirName eq "IFD0"
!ll&&!rl&&r
500
MC/DC0%0/3
$et->{"TIFF_TYPE"} eq "MRW" and $dirName eq "IFD0" and $et->{"Model"} =~ /^DiMAGE A200/
$et->{"TIFF_TYPE"} eq "MRW" $dirName eq "IFD0" $et->{"Model"} =~ /^DiMAGE A200/
Truth table25%1/4
A and B and C
A= $et->{"TIFF_TYPE"} eq "MRW"B= $dirName eq "IFD0"C= $et->{"Model"} =~ /^DiMAGE A200/
ABCresult
0XX0
10X0
1100
1111
504 # (don't test 3FR, RWL or RW2 files)
505 5 ▶ return if $$et{TIFF_TYPE} =~ /^(3FR|RWL|RW2)$/;
Branch: 1 branch
BranchTrueFalseTotal
if $et->{"TIFF_TYPE"} =~ /^(3FR|RWL|RW2)$/ 0 5 5
506  
507 5 Image::ExifTool::Exif::ValidateImageData($et, $offsetInfo, $dirName);
508  
509 # loop through all offsets
510 5 ▶ while (%$offsetInfo) {
Branch: 1 branch
BranchTrueFalseTotal
if (%$offsetInfo) 16 5 21
511 16 my ($id1) = sort keys %$offsetInfo;
512 16 my $offsets = $$offsetInfo{$id1};
513 16 delete $$offsetInfo{$id1};
514 16 ▶ next unless ref $offsets eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $offsets eq "ARRAY" 10 6 16
515 6 my $id2 = $$offsets[0]{OffsetPair};
516 6 ▶ unless (defined $id2 and $$offsetInfo{$id2}) {
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $id2 and $offsetInfo->{$id2}) 2 4 6
Condition66%2/3
defined $id2 and $offsetInfo->{$id2}
!ll&&!rl&&r
024
MC/DC50%1/2
defined $id2 and $offsetInfo->{$id2}
defined $id2 $offsetInfo->{$id2}
Truth table66%2/3
A and B
A= defined $id2B= $offsetInfo->{$id2}
ABresult
0X0
100
111
517 2 ▶ unless ($$offsets[0]{NotRealPair} or (defined $id2 and $id2 == -1)) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($offsets->[0]{"NotRealPair"} or defined $id2 and $id2 == -1) 2 0 2
Condition33%2/6
$offsets->[0]{"NotRealPair"} or defined $id2 and $id2 == -1
l!l&&r!l&&!r
002
defined $id2 and $id2 == -1
!ll&&!rl&&r
020
MC/DC0%0/3
$offsets->[0]{"NotRealPair"} or defined $id2 and $id2 == -1
$offsets->[0]{"NotRealPair"} defined $id2 $id2 == -1
Truth table25%1/4
A or B and C
A= $offsets->[0]{"NotRealPair"}B= defined $id2C= $id2 == -1
ABCresult
1XX1
0111
00X0
0100
518 2 ▶ my $corr = $$offsets[0]{IsOffset} ? 'size' : 'offset';
Branch: 1 branch
BranchTrueFalseTotal
$offsets->[0]{'IsOffset'} ? : 1 1 2
519 2 ▶ $et->Warn("$dirName:$$offsets[0]{Name} is missing the corresponding $corr tag") unless $minor;
Branch: 1 branch
BranchTrueFalseTotal
unless $minor 0 2 2
520 }
521 2 next;
522 }
523 4 my $sizes = $$offsetInfo{$id2};
524 4 delete $$offsetInfo{$id2};
525 4 ▶ ($sizes, $offsets) = ($offsets, $sizes) if $$sizes[0]{IsOffset};
Branch: 1 branch
BranchTrueFalseTotal
if $sizes->[0]{"IsOffset"} 0 4 4
526 4 my @offsets = split ' ', $$offsets[1];
527 4 my @sizes = split ' ', $$sizes[1];
528 4 ▶ if (@sizes != @offsets) {
Branch: 1 branch
BranchTrueFalseTotal
if (@sizes != @offsets) 0 4 4
529 $et->Warn(sprintf('Wrong number of values in %s 0x%.4x %s',
530 0 $dirName, $$offsets[0]{TagID}, $$offsets[0]{Name}), $minor);
531 0 next;
532 }
533 4 ▶ while (@offsets) {
Branch: 1 branch
BranchTrueFalseTotal
if (@offsets) 4 4 8
534 4 my $start = pop @offsets;
535 4 my $end = $start + pop @sizes;
536 4 ▶ $et->Warn("$dirName:$$offsets[0]{Name} is zero", $minor) if $start == 0;
Branch: 1 branch
BranchTrueFalseTotal
if $start == 0 0 4 4
537 4 ▶ $et->Warn("$dirName:$$sizes[0]{Name} is zero", $minor) if $start == $end;
Branch: 1 branch
BranchTrueFalseTotal
if $start == $end 0 4 4
538 4 ▶ next unless $end > $fileSize;
Branch: 1 branch
BranchTrueFalseTotal
unless $end > $fileSize 4 0 4
539 0 ▶ if ($start >= $fileSize) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start >= $fileSize) { } 0 0 0
540 0 ▶ if ($start == 0xffffffff) {
Branch: 1 branch
BranchTrueFalseTotal
if ($start == 4294967295) { } 0 0 0
541 0 $et->Warn("$dirName:$$offsets[0]{Name} is invalid (0xffffffff)", $minor);
542 } else {
543 0 $et->Warn("$dirName:$$offsets[0]{Name} is past end of file", $minor);
544 }
545 } else {
546 0 $et->Warn("$dirName:$$offsets[0]{Name}+$$sizes[0]{Name} runs past end of file", $minor);
547 }
548 0 last;
549 }
550 }
551 }
552  
553 #------------------------------------------------------------------------------
554 # Finish Validating tags
555 # Inputs: 0) ExifTool ref, 1) True to generate Validate tag
556 sub FinishValidate($$)
557 1 ▶{
Subroutine FinishValidate: called CC=48 SCAR=70.8
Pod undocumented
558 1 local $_;
559 1 my ($et, $mkTag) = @_;
560  
561 1 ▶ my $fileType = $$et{FILE_TYPE} || '';
Condition50%1/2
$et->{'FILE_TYPE'} || ''
l!l
10
MC/DC0%0/1
$et->{'FILE_TYPE'} || ''
$et->{'FILE_TYPE'}
Truth table50%1/2
A
A= $et->{'FILE_TYPE'}
Aresult
11
00
562 1 ▶ $fileType = $$et{TIFF_TYPE} if $fileType eq 'TIFF';
Branch: 1 branch
BranchTrueFalseTotal
if $fileType eq "TIFF" 1 0 1
563  
564 1 ▶ if ($validValue{$fileType}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($validValue{$fileType}) 0 1 1
565 0 my ($grp, $tag, %val);
566 0 local $SIG{'__WARN__'} = \&Image::ExifTool::SetWarning;
567 0 foreach $grp (sort keys %{$validValue{$fileType}}) {
568 0 ▶ next unless $$et{FOUND_DIR}{$grp};
Branch: 1 branch
BranchTrueFalseTotal
unless $et->{"FOUND_DIR"}{$grp} 0 0 0
569 0 my ($key, %val, %info, $minor, $verTag, $ver, $vstr);
570 0 my $verCheck = $verCheck{$grp};
571 0 ▶ if ($verCheck) {
Branch: 1 branch
BranchTrueFalseTotal
if ($verCheck) 0 0 0
572 0 ($verTag) = keys %$verCheck;
573 0 ($ver = $$et{VALUE}{$verTag}) =~ tr/0-9//dc; # (remove non-digits)
574 0 ▶ undef $ver unless $ver =~ /^\d{4}$/; # (already warned if invalid version)
Branch: 1 branch
BranchTrueFalseTotal
unless $ver =~ /^\d{4}$/ 0 0 0
575 }
576 # get all tags in this group
577 0 foreach $key (sort keys %{$$et{VALUE}}) {
578 0 ▶ next unless $et->GetGroup($key, 1) eq $grp;
Branch: 1 branch
BranchTrueFalseTotal
unless $et->GetGroup($key, 1) eq $grp 0 0 0
579 0 ▶ next if $$et{TAG_EXTRA}{$key}{G3}; # ignore sub-documents
Branch: 1 branch
BranchTrueFalseTotal
if $et->{"TAG_EXTRA"}{$key}{"G3"} 0 0 0
580 # fill in %val lookup with values based on tag ID
581 0 my $tag = $$et{TAG_INFO}{$key}{TagID};
582 0 $val{$tag} = $$et{VALUE}{$key};
583 # save TagInfo ref for later
584 0 $info{$tag} = $$et{TAG_INFO}{$key};
585 0 ▶ next unless defined $ver;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $ver 0 0 0
586 0 my $chk = $$verCheck{$verTag};
587 0 ▶ next if not defined $$chk{$tag} or $$chk{$tag} == 1 or $ver >= $$chk{$tag};
Branch: 1 branch
BranchTrueFalseTotal
if not defined $chk->{$tag} or $chk->{$tag} == 1 or $ver >= $chk->{$tag} 0 0 0
Condition0%0/6
not defined $chk->{$tag} or $chk->{$tag} == 1 or $ver >= $chk->{$tag}
l!l&&r!l&&!r
000
not defined $chk->{$tag} or $chk->{$tag} == 1
l!l&&r!l&&!r
000
MC/DC0%0/3
not defined $chk->{$tag} or $chk->{$tag} == 1 or $ver >= $chk->{$tag}
not defined $chk->{$tag} $chk->{$tag} == 1 $ver >= $chk->{$tag}
Truth table0%0/4
not(A) or B or C
A= not defined $chk->{$tag}B= $chk->{$tag} == 1C= $ver >= $chk->{$tag}
ABCresult
1XX1
01X1
0011
0000
588 0 ▶ if ($verTag eq 'GPSVersionID') {
Branch: 1 branch
BranchTrueFalseTotal
if ($verTag eq 'GPSVersionID') { } 0 0 0
589 0 ($vstr = $$chk{$tag}) =~ s/^(\d)(\d)(\d)/$1.$2.$3./;
590 } else {
591 0 $vstr = sprintf('%.4d', $$chk{$tag});
592 }
593 $et->Warn(sprintf('%s tag 0x%.4x %s requires %s %s or higher',
594 0 $grp, $tag, $$et{TAG_INFO}{$key}{Name}, $verTag, $vstr));
595 }
596 # make quick lookup for values based on tag ID
597 0 my $validValue = $validValue{$fileType}{$grp};
598 0 foreach $tag (sort { $a <=> $b } keys %$validValue) {
599 0 my $val = $val{$tag};
600 0 my ($pre, $post);
601 0 ▶ if (defined $$validValue{$tag}) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $validValue->{$tag}) { } 0 0 0
602 #### eval ($val, %val)
603 0 my $result = eval $$validValue{$tag};
604 0 ▶ if (not defined $result) {
Branch: 2 branches
BranchTrueFalseTotal
if (not defined $result) { } 0 0 0
elsif ($result eq '') { } 0 0 0
605 0 $pre = 'Internal error validating';
606 } elsif ($result eq '') {
607 0 ▶ $pre = defined $val ? 'Invalid value for' : "Missing required $fileType";
Branch: 1 branch
BranchTrueFalseTotal
defined $val ? : 0 0 0
608 } else {
609 0 ▶ next if $result eq '1';
Branch: 1 branch
BranchTrueFalseTotal
if $result eq 1 0 0 0
610 0 $pre = $result;
611 }
612 } else {
613 0 ▶ next unless defined $val;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $val 0 0 0
614 0 $post = "is not allowed in $fileType";
615 0 $minor = 1;
616 }
617 0 my $name;
618 0 ▶ if ($info{$tag}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($info{$tag}) { } 0 0 0
619 0 $name = $info{$tag}{Name};
620 } else {
621 0 ▶ my $table = 'Image::ExifTool::'.($grp eq 'GPS' ? 'GPS' : 'Exif').'::Main';
Branch: 1 branch
BranchTrueFalseTotal
$grp eq 'GPS' ? : 0 0 0
622 0 my $tagInfo = GetTagTable($table)->{$tag};
623 0 ▶ $tagInfo = $$tagInfo[0] if ref $tagInfo eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
if ref $tagInfo eq "ARRAY" 0 0 0
624 0 ▶ $name = $tagInfo ? $$tagInfo{Name} : '<unknown>';
Branch: 1 branch
BranchTrueFalseTotal
$tagInfo ? : 0 0 0
625 }
626 0 ▶ next if $$et{WrongFormat} and $$et{WrongFormat}{"$grp:$name"};
Branch: 1 branch
BranchTrueFalseTotal
if $et->{"WrongFormat"} and $et->{"WrongFormat"}{"${grp}:$name"} 0 0 0
Condition0%0/3
$et->{"WrongFormat"} and $et->{"WrongFormat"}{"${grp}:$name"}
!ll&&!rl&&r
000
MC/DC0%0/2
$et->{"WrongFormat"} and $et->{"WrongFormat"}{"${grp}:$name"}
$et->{"WrongFormat"} $et->{"WrongFormat"}{"${grp}:$name"}
Truth table0%0/3
A and B
A= $et->{"WrongFormat"}B= $et->{"WrongFormat"}{"${grp}:$name"}
ABresult
0X0
100
111
627 0 ▶ $pre ? ($pre .= ' ') : ($pre = '');
Branch: 1 branch
BranchTrueFalseTotal
$pre ? : 0 0 0
628 0 ▶ $post ? ($post = ' '.$post) : ($post = '');
Branch: 1 branch
BranchTrueFalseTotal
$post ? : 0 0 0
629 0 $et->Warn(sprintf('%s%s tag 0x%.4x %s%s', $pre, $grp, $tag, $name, $post), $minor);
630 }
631 }
632 }
633 # validate file extension
634 1 ▶ if ($$et{FILENAME} ne '') {
Branch: 1 branch
BranchTrueFalseTotal
if ($et->{"FILENAME"} ne "") 1 0 1
635 1 ▶ my $fileExt = ($$et{FILENAME} =~ /^.*\.([^.]+)$/s) ? uc($1) : '';
Branch: 1 branch
BranchTrueFalseTotal
$et->{'FILENAME'} =~ /^.*\.([^.]+)$/s ? : 1 0 1
636 1 my $extFileType = Image::ExifTool::GetFileType($fileExt);
637 1 ▶ if ($extFileType and $extFileType ne $fileType) {
Branch: 1 branch
BranchTrueFalseTotal
if ($extFileType and $extFileType ne $fileType) 1 0 1
Condition33%1/3
$extFileType and $extFileType ne $fileType
!ll&&!rl&&r
001
MC/DC0%0/2
$extFileType and $extFileType ne $fileType
$extFileType $extFileType ne $fileType
Truth table33%1/3
A and B
A= $extFileTypeB= $extFileType ne $fileType
ABresult
0X0
100
111
638 1 my $normExt = $$et{VALUE}{FileTypeExtension};
639 1 ▶ if ($normExt and $normExt ne $fileExt) {
Branch: 1 branch
BranchTrueFalseTotal
if ($normExt and $normExt ne $fileExt) 0 1 1
Condition33%1/3
$normExt and $normExt ne $fileExt
!ll&&!rl&&r
010
MC/DC0%0/2
$normExt and $normExt ne $fileExt
$normExt $normExt ne $fileExt
Truth table33%1/3
A and B
A= $normExtB= $normExt ne $fileExt
ABresult
0X0
100
111
640 0 my $lkup = $Image::ExifTool::fileTypeLookup{$fileExt};
641 0 ▶ if (ref $lkup or $lkup ne $normExt) {
Branch: 1 branch
BranchTrueFalseTotal
if (ref $lkup or $lkup ne $normExt) 0 0 0
Condition0%0/3
ref $lkup or $lkup ne $normExt
l!l&&r!l&&!r
000
MC/DC0%0/2
ref $lkup or $lkup ne $normExt
ref $lkup $lkup ne $normExt
Truth table0%0/3
A or B
A= ref $lkupB= $lkup ne $normExt
ABresult
1X1
011
000
642 0 $et->Warn("File has wrong extension (should be $normExt, not $fileExt)");
643 }
644 }
645 }
646 }
647 # issue warning if FastScan option used
648 1 ▶ $et->Warn('Validation incomplete because FastScan option used') if $et->Options('FastScan');
Branch: 1 branch
BranchTrueFalseTotal
if $et->Options("FastScan") 0 1 1
649  
650 # generate Validate tag if necessary
651 1 ▶ if ($mkTag) {
Branch: 1 branch
BranchTrueFalseTotal
if ($mkTag) 1 0 1
652 1 my (@num, $key);
653 push @num, $$et{VALUE}{Error} ? ($$et{DUPL_TAG}{Error} || 0) + 1 : 0,
654 1 ▶ $$et{VALUE}{Warning} ? ($$et{DUPL_TAG}{Warning} || 0) + 1 : 0, 0;
Branch: 2 branches
BranchTrueFalseTotal
$et->{'VALUE'}{'Error'} ? : 0 1 1
$et->{'VALUE'}{'Warning'} ? : 0 1 1
Condition0%0/4
$et->{'DUPL_TAG'}{'Error'} || 0
l!l
00
$et->{'DUPL_TAG'}{'Warning'} || 0
l!l
00
MC/DC0%0/1
$et->{'DUPL_TAG'}{'Error'} || 0
$et->{'DUPL_TAG'}{'Error'}
MC/DC0%0/1
$et->{'DUPL_TAG'}{'Warning'} || 0
$et->{'DUPL_TAG'}{'Warning'}
Truth table0%0/2
A
A= $et->{'DUPL_TAG'}{'Error'}
Aresult
11
00
Truth table0%0/2
A
A= $et->{'DUPL_TAG'}{'Warning'}
Aresult
11
00
655 1 for ($key = 'Warning'; ; ) {
656 1 ▶ ++$num[2] if $$et{VALUE}{$key} and $$et{VALUE}{$key} =~ /^\[minor\]/i;
Branch: 1 branch
BranchTrueFalseTotal
if $et->{"VALUE"}{$key} and $et->{"VALUE"}{$key} =~ /^\[minor\]/i 0 1 1
Condition33%1/3
$et->{"VALUE"}{$key} and $et->{"VALUE"}{$key} =~ /^\[minor\]/i
!ll&&!rl&&r
100
MC/DC0%0/2
$et->{"VALUE"}{$key} and $et->{"VALUE"}{$key} =~ /^\[minor\]/i
$et->{"VALUE"}{$key} $et->{"VALUE"}{$key} =~ /^\[minor\]/i
Truth table33%1/3
A and B
A= $et->{"VALUE"}{$key}B= $et->{"VALUE"}{$key} =~ /^\[minor\]/i
ABresult
0X0
100
111
657 1 ▶ $key = $et->NextTagKey($key) or last;
Branch: 1 branch
BranchTrueFalseTotal
$key = $et->NextTagKey($key) or last 0 1 1
658 }
659 1 $et->FoundTag(Validate => "@num");
660 }
661 }
662  
663 1 1; # end
664  
665 __END__
« Image/ExifTool/WritePDF.pl ↑ Summary Image/ExifTool/MacOS.pm »