summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Arthur <paul.arthur@flowerysong.com>2013-02-11 15:09:17 -0500
committerPaul Arthur <paul.arthur@flowerysong.com>2013-02-11 17:23:34 -0500
commitf447075a6a9414c0bbd553abbc2dc509a9764797 (patch)
tree61a5b9b79be6a2f8fc691f5e4dab4c066615ef8b
parent5bc48fd3b2035e11b137b660bf17c6878c0f1a86 (diff)
downloadampache-f447075a6a9414c0bbd553abbc2dc509a9764797.tar.gz
ampache-f447075a6a9414c0bbd553abbc2dc509a9764797.tar.bz2
ampache-f447075a6a9414c0bbd553abbc2dc509a9764797.zip
getID3: Import bugfix from forum
Multi-valued ID3v2 tags are now split properly. Pondering whether this breaks anything...
-rw-r--r--modules/getid3/module.tag.id3v2.php36
1 files changed, 32 insertions, 4 deletions
diff --git a/modules/getid3/module.tag.id3v2.php b/modules/getid3/module.tag.id3v2.php
index 3704b64b..eac73d71 100644
--- a/modules/getid3/module.tag.id3v2.php
+++ b/modules/getid3/module.tag.id3v2.php
@@ -666,10 +666,38 @@ class getid3_id3v2 extends getid3_handler
$parsedFrame['encoding'] = $this->TextEncodingNameLookup($frame_textencoding);
if (!empty($parsedFrame['framenameshort']) && !empty($parsedFrame['data'])) {
- $string = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $parsedFrame['data']);
- $string = rtrim($string, "\x00"); // remove possible terminating null (put by encoding id or software bug)
- $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $string;
- unset($string);
+ // ID3v2.3 specs say that TPE1 (and others) can contain multiple artist values separated with /
+ // This of course breaks when an aritst name contains slash character, e.g. "AC/DC"
+ // MP3tag (maybe others) implement alternative system where multiple artists are null-separated, which makes more sense
+ // getID3 will split null-separated artists into multiple artists and leave slash-separated ones to the user
+ switch ($parsedFrame['encoding']) {
+ case 'UTF-16':
+ case 'UTF-16BE':
+ case 'UTF-16LE':
+ $wordsize = 2;
+ break;
+ case 'ISO-8859-1':
+ case 'UTF-8':
+ default:
+ $wordsize = 1;
+ break;
+ }
+ $Txxx_elements = array();
+ $Txxx_elements_start_offset = 0;
+ for ($i = 0; $i < strlen($parsedFrame['data']); $i += $wordsize) {
+ if (substr($parsedFrame['data'], $i, $wordsize) == str_repeat("\x00", $wordsize)) {
+ $Txxx_elements[] = substr($parsedFrame['data'], $Txxx_elements_start_offset, $i - $Txxx_elements_start_offset);
+ $Txxx_elements_start_offset = $i + $wordsize;
+ }
+ }
+ $Txxx_elements[] = substr($parsedFrame['data'], $Txxx_elements_start_offset, $i - $Txxx_elements_start_offset);
+ foreach ($Txxx_elements as $Txxx_element) {
+ $string = getid3_lib::iconv_fallback($parsedFrame['encoding'], $info['id3v2']['encoding'], $Txxx_element);
+ if (!empty($string)) {
+ $info['id3v2']['comments'][$parsedFrame['framenameshort']][] = $string;
+ }
+ }
+ unset($string, $wordsize, $i, $Txxx_elements, $Txxx_element, $Txxx_elements_start_offset);
}
} elseif ((($id3v2_majorversion >= 3) && ($parsedFrame['frame_name'] == 'WXXX')) || // 4.3.2 WXXX User defined URL link frame