[SPIP] ~maj v3.2.9-->v3.2.11
[lhc/web/www.git] / www / plugins-dist / medias / lib / getid3 / module.tag.apetag.php
index 37971a6..26be982 100644 (file)
 //                                                            ///
 /////////////////////////////////////////////////////////////////
 
+if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
+       exit;
+}
+
 class getid3_apetag extends getid3_handler
 {
        /**
@@ -162,8 +166,8 @@ class getid3_apetag extends getid3_handler
                        switch (strtolower($item_key)) {
                                // http://wiki.hydrogenaud.io/index.php?title=ReplayGain#MP3Gain
                                case 'replaygain_track_gain':
-                                       if (preg_match('#^[\\-\\+][0-9\\.,]{8}$#', $thisfile_ape_items_current['data'][0])) {
-                                               $thisfile_replaygain['track']['adjustment'] = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero!
+                                       if (preg_match('#^([\\-\\+][0-9\\.,]{8})( dB)?$#', $thisfile_ape_items_current['data'][0], $matches)) {
+                                               $thisfile_replaygain['track']['adjustment'] = (float) str_replace(',', '.', $matches[1]); // float casting will see "0,95" as zero!
                                                $thisfile_replaygain['track']['originator'] = 'unspecified';
                                        } else {
                                                $this->warning('MP3gainTrackGain value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"');
@@ -171,8 +175,8 @@ class getid3_apetag extends getid3_handler
                                        break;
 
                                case 'replaygain_track_peak':
-                                       if (preg_match('#^[0-9\\.,]{8}$#', $thisfile_ape_items_current['data'][0])) {
-                                               $thisfile_replaygain['track']['peak']       = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero!
+                                       if (preg_match('#^([0-9\\.,]{8})$#', $thisfile_ape_items_current['data'][0], $matches)) {
+                                               $thisfile_replaygain['track']['peak']       = (float) str_replace(',', '.', $matches[1]); // float casting will see "0,95" as zero!
                                                $thisfile_replaygain['track']['originator'] = 'unspecified';
                                                if ($thisfile_replaygain['track']['peak'] <= 0) {
                                                        $this->warning('ReplayGain Track peak from APEtag appears invalid: '.$thisfile_replaygain['track']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")');
@@ -183,8 +187,8 @@ class getid3_apetag extends getid3_handler
                                        break;
 
                                case 'replaygain_album_gain':
-                                       if (preg_match('#^[\\-\\+][0-9\\.,]{8}$#', $thisfile_ape_items_current['data'][0])) {
-                                               $thisfile_replaygain['album']['adjustment'] = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero!
+                                       if (preg_match('#^([\\-\\+][0-9\\.,]{8})( dB)?$#', $thisfile_ape_items_current['data'][0], $matches)) {
+                                               $thisfile_replaygain['album']['adjustment'] = (float) str_replace(',', '.', $matches[1]); // float casting will see "0,95" as zero!
                                                $thisfile_replaygain['album']['originator'] = 'unspecified';
                                        } else {
                                                $this->warning('MP3gainAlbumGain value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"');
@@ -192,8 +196,8 @@ class getid3_apetag extends getid3_handler
                                        break;
 
                                case 'replaygain_album_peak':
-                                       if (preg_match('#^[0-9\\.,]{8}$#', $thisfile_ape_items_current['data'][0])) {
-                                               $thisfile_replaygain['album']['peak']       = (float) str_replace(',', '.', $thisfile_ape_items_current['data'][0]); // float casting will see "0,95" as zero!
+                                       if (preg_match('#^([0-9\\.,]{8})$#', $thisfile_ape_items_current['data'][0], $matches)) {
+                                               $thisfile_replaygain['album']['peak']       = (float) str_replace(',', '.', $matches[1]); // float casting will see "0,95" as zero!
                                                $thisfile_replaygain['album']['originator'] = 'unspecified';
                                                if ($thisfile_replaygain['album']['peak'] <= 0) {
                                                        $this->warning('ReplayGain Album peak from APEtag appears invalid: '.$thisfile_replaygain['album']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")');
@@ -237,7 +241,7 @@ class getid3_apetag extends getid3_handler
                                case 'tracknumber':
                                        if (is_array($thisfile_ape_items_current['data'])) {
                                                foreach ($thisfile_ape_items_current['data'] as $comment) {
-                                                       $thisfile_ape['comments']['track'][] = $comment;
+                                                       $thisfile_ape['comments']['track_number'][] = $comment;
                                                }
                                        }
                                        break;