mirror of
https://github.com/samsonjs/media.git
synced 2026-03-26 09:35:47 +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);
|
||||
String description = new String(data, 0, descriptionEndIndex, charset);
|
||||
|
||||
String value;
|
||||
int valueStartIndex = descriptionEndIndex + delimiterLength(encoding);
|
||||
int valueEndIndex = indexOfEos(data, valueStartIndex, encoding);
|
||||
String value = new String(data, valueStartIndex, valueEndIndex - valueStartIndex, charset);
|
||||
if (valueStartIndex < data.length) {
|
||||
int valueEndIndex = indexOfEos(data, valueStartIndex, encoding);
|
||||
value = new String(data, valueStartIndex, valueEndIndex - valueStartIndex, charset);
|
||||
} else {
|
||||
value = "";
|
||||
}
|
||||
|
||||
return new TxxxFrame(description, value);
|
||||
}
|
||||
|
|
@ -408,15 +413,25 @@ public final class Id3Decoder implements MetadataDecoder {
|
|||
int descriptionEndIndex = indexOfEos(data, 0, encoding);
|
||||
String description = new String(data, 0, descriptionEndIndex, charset);
|
||||
|
||||
String text;
|
||||
int textStartIndex = descriptionEndIndex + delimiterLength(encoding);
|
||||
int textEndIndex = indexOfEos(data, textStartIndex, encoding);
|
||||
String text = new String(data, textStartIndex, textEndIndex - textStartIndex, charset);
|
||||
if (textStartIndex < data.length) {
|
||||
int textEndIndex = indexOfEos(data, textStartIndex, encoding);
|
||||
text = new String(data, textStartIndex, textEndIndex - textStartIndex, charset);
|
||||
} else {
|
||||
text = "";
|
||||
}
|
||||
|
||||
return new CommentFrame(language, description, text);
|
||||
}
|
||||
|
||||
private static TextInformationFrame decodeTextInformationFrame(ParsableByteArray id3Data,
|
||||
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();
|
||||
String charset = getCharsetName(encoding);
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue