Subject: | Multi-Value Text Data Fields |
Date: | Thu, 1 Nov 2007 09:27:40 -0700 (PDT) |
To: | bug-MP3-Tag [...] rt.cpan.org |
From: | Dave Bloom <dave [...] digitalnoise.net> |
MP3-Tag v0.9709
ActivePerl v5.8.8 build 822
Windows XP SP2
Text data fields in the ID3v2 format allow muliple values to be entered;
however, the null separator character used to identify these multiple
values is being replaced with a separator that is not unique, making it
impossible to programatically distinguish the mutiple values.
From http://www.id3.org/id3v2.4.0-frames
4.2. Text information frames
The text information frames are often the most important frames,
containing information like artist, album and more. There may only be
one text information frame of its kind in an tag. All text
information frames supports multiple strings, stored as a null
separated list, where null is reperesented by the termination code
for the charater encoding.
For instance the frame TIT2 (Title/songname/content description) can
contain up to three values. These values are separated by the \x00
value. It should be possible to split that field into its multiple
values based on using \x00 as the separator.
The extract_data subroutine in ID3v2.pm is replacing this separator with
" / ", which is not unique enough to guarantee that the multiple values
can be distinguished.
Removing the line in the subroutine extract_data that replaces the \x00
charaters within the data string is a simple solution to this problem, as
it provides the programmer with a unique charater separator that will
never be part of the data. This allows easy determination of multiple
values.
Exiting code (lines 1840-1844 of ID3v2.pm):
unless (exists $rule->{data} || !defined $found) {
$found =~ s/[\x00]+$//; # some progs pad text fields with \x00
$found =~ s![\x00]! / !g; # some progs use \x00 inside a text string to seperate text strings
$found =~ s/ +$//; # no trailing spaces after the text
}
Fix:
unless (exists $rule->{data} || !defined $found) {
$found =~ s/[\x00]+$//; # some progs pad text fields with \x00
$found =~ s/ +$//; # no trailing spaces after the text
}
-Dave
---
Dave Bloom http://www.digitalnoise.net
It happens sometimes. People just expolode. Natural causes.
- "Repo Man"