Skip to content

Commit 7c4d49a

Browse files
authored
Fixing GEOB bug (#96)
1 parent a7acf23 commit 7c4d49a

2 files changed

Lines changed: 36 additions & 2 deletions

File tree

src/id3v2/frames/attachmentFrame.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ export default class AttachmentFrame extends Frame implements IPicture {
429429
// Filename <text string according to encoding> $00 (00)
430430
// Content description <text string according to encoding> $00 (00)
431431
// Encapsulated object <binary data>
432-
const mimeTypeEndIndex = data.find(ByteVector.getTextDelimiter(StringType.Latin1));
432+
const mimeTypeEndIndex = data.offsetFind(ByteVector.getTextDelimiter(StringType.Latin1), 1);
433433
if (mimeTypeEndIndex === -1) {
434434
return;
435435
}

test-unit/id3v2/attachmentsFrameTests.ts

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ const getCustomTestFrame = (
240240
}
241241

242242
@test
243-
public fromRawData_geob() {
243+
public fromRawData_geob_nonLatinEncoding() {
244244
// Arrange
245245
const testData = ByteVector.fromString("fuxbuxqux", StringType.Latin1);
246246
const header = new Id3v2FrameHeader(FrameIdentifiers.GEOB);
@@ -273,6 +273,40 @@ const getCustomTestFrame = (
273273
);
274274
}
275275

276+
@test
277+
public fromRawData_geob_latinEncoding() {
278+
// Arrange
279+
const testData = ByteVector.fromString("fuxbuxqux", StringType.Latin1);
280+
const header = new Id3v2FrameHeader(FrameIdentifiers.GEOB);
281+
header.frameSize = 60;
282+
const data = ByteVector.concatenate(
283+
header.render(4),
284+
StringType.Latin1,
285+
ByteVector.fromString("image/gif", StringType.Latin1),
286+
ByteVector.getTextDelimiter(StringType.Latin1),
287+
ByteVector.fromString("image.gif", StringType.Latin1),
288+
ByteVector.getTextDelimiter(StringType.Latin1),
289+
ByteVector.fromString("foobarbaz", StringType.Latin1),
290+
ByteVector.getTextDelimiter(StringType.Latin1),
291+
testData
292+
);
293+
294+
// Act
295+
const frame = AttachmentFrame.fromRawData(data, 4);
296+
297+
// Assert
298+
Id3v2_AttachmentFrame_ConstructorTests.verifyFrame(
299+
frame,
300+
FrameIdentifiers.GEOB,
301+
testData,
302+
"foobarbaz",
303+
"image.gif",
304+
"image/gif",
305+
StringType.Latin1,
306+
PictureType.NotAPicture
307+
);
308+
}
309+
276310
@test
277311
public fromOffsetRawData_apicV4() {
278312
// Arrange

0 commit comments

Comments
 (0)