mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Handle ID3 frames that end with empty text field
Issue: #2309 ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=144061654
This commit is contained in:
parent
bf65df1b35
commit
deefe50abc
1 changed files with 19 additions and 4 deletions
|
|
@ -308,9 +308,14 @@ public final class Id3Decoder implements MetadataDecoder {
|
||||||
int descriptionEndIndex = indexOfEos(data, 0, encoding);
|
int descriptionEndIndex = indexOfEos(data, 0, encoding);
|
||||||
String description = new String(data, 0, descriptionEndIndex, charset);
|
String description = new String(data, 0, descriptionEndIndex, charset);
|
||||||
|
|
||||||
|
String value;
|
||||||
int valueStartIndex = descriptionEndIndex + delimiterLength(encoding);
|
int valueStartIndex = descriptionEndIndex + delimiterLength(encoding);
|
||||||
int valueEndIndex = indexOfEos(data, valueStartIndex, encoding);
|
if (valueStartIndex < data.length) {
|
||||||
String value = new String(data, valueStartIndex, valueEndIndex - valueStartIndex, charset);
|
int valueEndIndex = indexOfEos(data, valueStartIndex, encoding);
|
||||||
|
value = new String(data, valueStartIndex, valueEndIndex - valueStartIndex, charset);
|
||||||
|
} else {
|
||||||
|
value = "";
|
||||||
|
}
|
||||||
|
|
||||||
return new TxxxFrame(description, value);
|
return new TxxxFrame(description, value);
|
||||||
}
|
}
|
||||||
|
|
@ -408,15 +413,25 @@ public final class Id3Decoder implements MetadataDecoder {
|
||||||
int descriptionEndIndex = indexOfEos(data, 0, encoding);
|
int descriptionEndIndex = indexOfEos(data, 0, encoding);
|
||||||
String description = new String(data, 0, descriptionEndIndex, charset);
|
String description = new String(data, 0, descriptionEndIndex, charset);
|
||||||
|
|
||||||
|
String text;
|
||||||
int textStartIndex = descriptionEndIndex + delimiterLength(encoding);
|
int textStartIndex = descriptionEndIndex + delimiterLength(encoding);
|
||||||
int textEndIndex = indexOfEos(data, textStartIndex, encoding);
|
if (textStartIndex < data.length) {
|
||||||
String text = new String(data, textStartIndex, textEndIndex - textStartIndex, charset);
|
int textEndIndex = indexOfEos(data, textStartIndex, encoding);
|
||||||
|
text = new String(data, textStartIndex, textEndIndex - textStartIndex, charset);
|
||||||
|
} else {
|
||||||
|
text = "";
|
||||||
|
}
|
||||||
|
|
||||||
return new CommentFrame(language, description, text);
|
return new CommentFrame(language, description, text);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static TextInformationFrame decodeTextInformationFrame(ParsableByteArray id3Data,
|
private static TextInformationFrame decodeTextInformationFrame(ParsableByteArray id3Data,
|
||||||
int frameSize, String id) throws UnsupportedEncodingException {
|
int frameSize, String id) throws UnsupportedEncodingException {
|
||||||
|
if (frameSize <= 1) {
|
||||||
|
// Frame is empty or contains only the text encoding byte.
|
||||||
|
return new TextInformationFrame(id, "");
|
||||||
|
}
|
||||||
|
|
||||||
int encoding = id3Data.readUnsignedByte();
|
int encoding = id3Data.readUnsignedByte();
|
||||||
String charset = getCharsetName(encoding);
|
String charset = getCharsetName(encoding);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue