New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Write TerminationBytes for id3.org spec compliance #33
Conversation
Hi! Thank you for your contribution. Can you please quote a text, where it's written? I can't find it.
And there is nothing written about termination bytes. |
And also this (http://id3.org/id3v2.4.0-frames):
|
There are some argues from google search about this.
From 4.2 in http://id3.org/id3v2.4.0-frames
|
It doesn't state it actually. It just shows the termination bytes for corresponding encodings, but nothing says that every encoded text should be terminated.
It only shows an example for Unicode-16 with BOM and only which are NULL-terminated:
Yes, there is nothing said about using one string in text frame, so if you use only one string in text frame with no termination, you don't violate the standard. 4 - I would like to add the writing the termination bytes for text frames, just for compatibility with Windows File Explorer. But please open the new issue for it with detailed description. 3, 5 - We should not rely on how other programs work, but on standards. |
It's really strange situation about the termination bytes of text frames, but just take a look on other frames like USLT or APIC at http://id3.org/id3v2.4.0-frames. You can see the explicit indication about the termination bytes at the end:
In docs about text frames I don't see it:
So I don't think WFE works according to standards. |
It's really not clear in spec. Hence compatibility will be good. In addition, in sec 4, frame overview from http://id3.org/id3v2.4.0-structure, it lists
or
for possible encodings of text. Doesn't it mean to prefix encoding byte and terminate the text with termination bytes?
|
|
@ericmurmur Please open a new issue with detailed description that WFE doesn't correctly read text frames, which are set with id3v2 library. |
Yes. So it means termination bytes shall be there for text string, doesn't it? And since Golang does not include termination bytes for string like c/c++, it shall be added, isn't it? In c/c++ library, termination bytes are already in their string buffer. |
I don't think so. There is no explicit information in standard that I must terminate strings in every text frame. |
Is the encoding byte added? Yes, right? In the standard, it lists all 4 encoding bytes. In every case, it has stated [Terminated with $00] or [Terminated with $00 00]. It is NOT optional.
Doesn't it mean to follow the encoding descriptions in http://id3.org/id3v2.4.0-structure, which has stated [[Terminated with $00] or [Terminated with $00 00] in all encoding cases? |
Hi @ericmurmur! I'm very sorry for so late answer, I had a lot of to do. I think, you were right in this discussion. Many sites and apps terminate text frames with Just replace following tests: // https://github.com/bogem/id3v2/issues/13.
// https://github.com/bogem/id3v2/commit/3845103da5b1698289b82a90f5d2559b770bd996
func TestParseV3UnsafeSize(t *testing.T) {
t.Parallel()
buf := new(bytes.Buffer)
title := strings.Repeat("A", 254)
tag := NewEmptyTag()
tag.SetVersion(3)
tag.SetTitle(title)
if _, err := tag.WriteTo(buf); err != nil {
t.Fatalf("Error while writing tag: %v", err)
}
titleFrameHeader := buf.Bytes()[tagHeaderSize : tagHeaderSize+frameHeaderSize]
expected := []byte{0, 0, 1, 0}
got := titleFrameHeader[4:8]
if !bytes.Equal(got, expected) {
t.Fatalf("Expected %v, got %v", expected, got)
}
parsedTag, err := ParseReader(buf, Options{Parse: true})
if err != nil {
t.Fatalf("Error while parsing tag: %v", err)
}
if parsedTag.Title() != title {
t.Fatalf("Titles are not equal: len(parsedTag.Title()) == %v, len(title) == %v", len(parsedTag.Title()), len(title))
}
} tag_test.go framesSize = 211948 |
And also please push new |
Closing in favour of #52 |
According to the spec http://id3.org/id3v2.4.0-structure,
TerminationBytes has to be in the text frame.
Some ID3 reader like Windows file explorer media file properties cannot handle such unicode text frames without proper TerminationBytes.