@@ -21,12 +21,12 @@ public sealed class IptcProfile : IDeepCloneable<IptcProfile>
21
21
private const uint MaxStandardDataTagSize = 0x7FFF ;
22
22
23
23
/// <summary>
24
- /// 1:90 Coded Character Set
24
+ /// 1:90 Coded Character Set.
25
25
/// </summary>
26
26
private const byte IptcEnvelopeCodedCharacterSet = 0x5A ;
27
27
28
28
/// <summary>
29
- /// This value marks that UTF-8 encoding is used in application records
29
+ /// This value marks that UTF-8 encoding is used in application records.
30
30
/// </summary>
31
31
private static readonly byte [ ] CodedCharacterSetUtf8Value = { 0x1B , 0x25 , 0x47 } ;
32
32
@@ -255,15 +255,15 @@ public void UpdateData()
255
255
256
256
if ( hasValuesInUtf8 )
257
257
{
258
- length += 5 + CodedCharacterSetUtf8Value . Length ; // additional length for UTF-8 Tag
258
+ length += 5 + CodedCharacterSetUtf8Value . Length ; // Additional length for UTF-8 Tag.
259
259
}
260
260
261
261
this . Data = new byte [ length ] ;
262
262
int i = 0 ;
263
263
264
264
if ( hasValuesInUtf8 )
265
265
{
266
- // Standard DataSet Tag
266
+ // Envelope Record.
267
267
this . Data [ i ++ ] = IptcTagMarkerByte ;
268
268
this . Data [ i ++ ] = 1 ; // Envelope
269
269
this . Data [ i ++ ] = IptcEnvelopeCodedCharacterSet ;
@@ -275,7 +275,7 @@ public void UpdateData()
275
275
276
276
foreach ( IptcValue value in this . Values )
277
277
{
278
- // Standard DataSet Tag
278
+ // Application Record.
279
279
// +-----------+----------------+---------------------------------------------------------------------------------+
280
280
// | Octet Pos | Name | Description |
281
281
// +==========-+================+=================================================================================+
@@ -327,6 +327,7 @@ private void Initialize()
327
327
bool isValidRecordNumber = recordNumber is >= 1 and <= 9 ;
328
328
var tag = ( IptcTag ) this . Data [ offset ++ ] ;
329
329
bool isValidEntry = isValidTagMarker && isValidRecordNumber ;
330
+ bool isApplicationRecord = recordNumber == 0x02 ;
330
331
331
332
uint byteCount = BinaryPrimitives . ReadUInt16BigEndian ( this . Data . AsSpan ( offset , 2 ) ) ;
332
333
offset += 2 ;
@@ -336,7 +337,7 @@ private void Initialize()
336
337
break ;
337
338
}
338
339
339
- if ( isValidEntry && byteCount > 0 && ( offset <= this . Data . Length - byteCount ) )
340
+ if ( isValidEntry && isApplicationRecord && byteCount > 0 && ( offset <= this . Data . Length - byteCount ) )
340
341
{
341
342
byte [ ] iptcData = new byte [ byteCount ] ;
342
343
Buffer . BlockCopy ( this . Data , offset , iptcData , 0 , ( int ) byteCount ) ;
@@ -348,9 +349,9 @@ private void Initialize()
348
349
}
349
350
350
351
/// <summary>
351
- /// Gets if any value has UTF-8 encoding
352
+ /// Gets if any value has UTF-8 encoding.
352
353
/// </summary>
353
- /// <returns>true if any value has UTF-8 encoding</returns>
354
+ /// <returns>true if any value has UTF-8 encoding. </returns>
354
355
private bool HasValuesInUtf8 ( )
355
356
{
356
357
foreach ( IptcValue value in this . values )
0 commit comments