Skip to content

Commit

Permalink
Restore endianness in tag value reading
Browse files Browse the repository at this point in the history
  • Loading branch information
bjornstar committed Jul 5, 2024
1 parent 9f7b8d1 commit a7a45ff
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions lib/id3v2/ID3v24TagMapper.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { INativeTagMap } from '../common/GenericTagTypes.js';
import { UINT32_LE } from 'token-types';
import { CommonTagMapper } from '../common/GenericTagMapper.js';
import { CaseInsensitiveTagMap } from '../common/CaseInsensitiveTagMap.js';
import * as util from '../common/Util.js';
import { decodeString } from '../common/Util.js';

import { INativeMetadataCollector } from '../common/MetadataCollector.js';
import { IRating, ITag } from '../type.js';
import type { INativeTagMap } from '../common/GenericTagTypes.js';
import type { INativeMetadataCollector } from '../common/MetadataCollector.js';
import type { IRating, ITag } from '../type.js';

/**
* ID3v2.3/ID3v2.4 tag mappings
Expand Down Expand Up @@ -171,7 +172,6 @@ export class ID3v24TagMapper extends CaseInsensitiveTagMap {
* Handle post mapping exceptions / correction
* @param tag to post map
* @param warnings Wil be used to register (collect) warnings
* @return Common value e.g. "Buena Vista Social Club"
*/
protected postMap(tag: ITag, warnings: INativeMetadataCollector): void {

Expand All @@ -180,7 +180,7 @@ export class ID3v24TagMapper extends CaseInsensitiveTagMap {
case 'UFID': // decode MusicBrainz Recording Id
if (tag.value.owner_identifier === 'http://musicbrainz.org') {
tag.id += ':' + tag.value.owner_identifier;
tag.value = util.decodeString(tag.value.identifier, 'latin1'); // latin1 == iso-8859-1
tag.value = decodeString(tag.value.identifier, 'latin1'); // latin1 == iso-8859-1
}
break;

Expand All @@ -190,7 +190,7 @@ export class ID3v24TagMapper extends CaseInsensitiveTagMap {
case 'AverageLevel':
case 'PeakValue':
tag.id += ':' + tag.value.owner_identifier;
tag.value = tag.value.data.length === 4 ? new DataView(tag.value.data.buffer).getUint32(0) : null;
tag.value = tag.value.data.length === 4 ? UINT32_LE.get(tag.value.data, 0) : null;
if (tag.value === null) {
warnings.addWarning(`Failed to parse PRIV:PeakValue`);
}
Expand Down

0 comments on commit a7a45ff

Please sign in to comment.