Make WordPress Core


Ignore:
Timestamp:
07/31/2017 07:49:31 PM (7 years ago)
Author:
wonderboymusic
Message:

Media: update the getID3 library to version 1.9.14 to avoid fatal errors in PHP7.

Props MyThemeShop for the initial patch.
Fixes #41496.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ID3/module.tag.apetag.php

    r32979 r41196  
    2424
    2525        if (!getid3_lib::intValueSupported($info['filesize'])) {
    26             $info['warning'][] = 'Unable to check for APEtags because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
     26            $this->warning('Unable to check for APEtags because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB');
    2727            return false;
    2828        }
     
    7373        $APEfooterData = $this->fread(32);
    7474        if (!($thisfile_ape['footer'] = $this->parseAPEheaderFooter($APEfooterData))) {
    75             $info['error'][] = 'Error parsing APE footer at offset '.$thisfile_ape['tag_offset_end'];
     75            $this->error('Error parsing APE footer at offset '.$thisfile_ape['tag_offset_end']);
    7676            return false;
    7777        }
     
    8989
    9090        if (isset($info['id3v1']['tag_offset_start']) && ($info['id3v1']['tag_offset_start'] < $thisfile_ape['tag_offset_end'])) {
    91             $info['warning'][] = 'ID3v1 tag information ignored since it appears to be a false synch in APEtag data';
     91            $this->warning('ID3v1 tag information ignored since it appears to be a false synch in APEtag data');
    9292            unset($info['id3v1']);
    9393            foreach ($info['warning'] as $key => $value) {
     
    105105                $offset += $apetagheadersize;
    106106            } else {
    107                 $info['error'][] = 'Error parsing APE header at offset '.$thisfile_ape['tag_offset_start'];
     107                $this->error('Error parsing APE header at offset '.$thisfile_ape['tag_offset_start']);
    108108                return false;
    109109            }
     
    120120            $offset += 4;
    121121            if (strstr(substr($APEtagData, $offset), "\x00") === false) {
    122                 $info['error'][] = 'Cannot find null-byte (0x00) seperator between ItemKey #'.$i.' and value. ItemKey starts '.$offset.' bytes into the APE tag, at file offset '.($thisfile_ape['tag_offset_start'] + $offset);
     122                $this->error('Cannot find null-byte (0x00) separator between ItemKey #'.$i.' and value. ItemKey starts '.$offset.' bytes into the APE tag, at file offset '.($thisfile_ape['tag_offset_start'] + $offset));
    123123                return false;
    124124            }
     
    155155                        $thisfile_replaygain['track']['originator'] = 'unspecified';
    156156                    } else {
    157                         $info['warning'][] = 'MP3gainTrackGain value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"';
     157                        $this->warning('MP3gainTrackGain value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"');
    158158                    }
    159159                    break;
     
    164164                        $thisfile_replaygain['track']['originator'] = 'unspecified';
    165165                        if ($thisfile_replaygain['track']['peak'] <= 0) {
    166                             $info['warning'][] = 'ReplayGain Track peak from APEtag appears invalid: '.$thisfile_replaygain['track']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")';
    167                         }
    168                     } else {
    169                         $info['warning'][] = 'MP3gainTrackPeak value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"';
     166                            $this->warning('ReplayGain Track peak from APEtag appears invalid: '.$thisfile_replaygain['track']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")');
     167                        }
     168                    } else {
     169                        $this->warning('MP3gainTrackPeak value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"');
    170170                    }
    171171                    break;
     
    176176                        $thisfile_replaygain['album']['originator'] = 'unspecified';
    177177                    } else {
    178                         $info['warning'][] = 'MP3gainAlbumGain value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"';
     178                        $this->warning('MP3gainAlbumGain value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"');
    179179                    }
    180180                    break;
     
    185185                        $thisfile_replaygain['album']['originator'] = 'unspecified';
    186186                        if ($thisfile_replaygain['album']['peak'] <= 0) {
    187                             $info['warning'][] = 'ReplayGain Album peak from APEtag appears invalid: '.$thisfile_replaygain['album']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")';
    188                         }
    189                     } else {
    190                         $info['warning'][] = 'MP3gainAlbumPeak value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"';
     187                            $this->warning('ReplayGain Album peak from APEtag appears invalid: '.$thisfile_replaygain['album']['peak'].' (original value = "'.$thisfile_ape_items_current['data'][0].'")');
     188                        }
     189                    } else {
     190                        $this->warning('MP3gainAlbumPeak value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"');
    191191                    }
    192192                    break;
     
    199199                        $thisfile_replaygain['mp3gain']['undo_wrap']  = (($mp3gain_undo_wrap == 'Y') ? true : false);
    200200                    } else {
    201                         $info['warning'][] = 'MP3gainUndo value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"';
     201                        $this->warning('MP3gainUndo value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"');
    202202                    }
    203203                    break;
     
    209209                        $thisfile_replaygain['mp3gain']['globalgain_track_max'] = intval($mp3gain_globalgain_max);
    210210                    } else {
    211                         $info['warning'][] = 'MP3gainMinMax value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"';
     211                        $this->warning('MP3gainMinMax value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"');
    212212                    }
    213213                    break;
     
    219219                        $thisfile_replaygain['mp3gain']['globalgain_album_max'] = intval($mp3gain_globalgain_album_max);
    220220                    } else {
    221                         $info['warning'][] = 'MP3gainAlbumMinMax value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"';
     221                        $this->warning('MP3gainAlbumMinMax value in APEtag appears invalid: "'.$thisfile_ape_items_current['data'][0].'"');
    222222                    }
    223223                    break;
     
    254254                    // list of possible cover arts from http://taglib-sharp.sourcearchive.com/documentation/2.0.3.0-2/Ape_2Tag_8cs-source.html
    255255                    if (is_array($thisfile_ape_items_current['data'])) {
    256                         $info['warning'][] = 'APEtag "'.$item_key.'" should be flagged as Binary data, but was incorrectly flagged as UTF-8';
     256                        $this->warning('APEtag "'.$item_key.'" should be flagged as Binary data, but was incorrectly flagged as UTF-8');
    257257                        $thisfile_ape_items_current['data'] = implode("\x00", $thisfile_ape_items_current['data']);
    258258                    }
     
    261261                    $thisfile_ape_items_current['data_length'] = strlen($thisfile_ape_items_current['data']);
    262262
    263                     $thisfile_ape_items_current['image_mime'] = '';
    264                     $imageinfo = array();
    265                     $imagechunkcheck = getid3_lib::GetDataImageSize($thisfile_ape_items_current['data'], $imageinfo);
    266                     $thisfile_ape_items_current['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]);
    267 
    268263                    do {
     264                        $thisfile_ape_items_current['image_mime'] = '';
     265                        $imageinfo = array();
     266                        $imagechunkcheck = getid3_lib::GetDataImageSize($thisfile_ape_items_current['data'], $imageinfo);
     267                        if (($imagechunkcheck === false) || !isset($imagechunkcheck[2])) {
     268                            $this->warning('APEtag "'.$item_key.'" contains invalid image data');
     269                            break;
     270                        }
     271                        $thisfile_ape_items_current['image_mime'] = image_type_to_mime_type($imagechunkcheck[2]);
     272
    269273                        if ($this->inline_attachments === false) {
    270274                            // skip entirely
     
    277281                            if ($this->inline_attachments < $thisfile_ape_items_current['data_length']) {
    278282                                // too big, skip
    279                                 $info['warning'][] = 'attachment at '.$thisfile_ape_items_current['offset'].' is too large to process inline ('.number_format($thisfile_ape_items_current['data_length']).' bytes)';
     283                                $this->warning('attachment at '.$thisfile_ape_items_current['offset'].' is too large to process inline ('.number_format($thisfile_ape_items_current['data_length']).' bytes)');
    280284                                unset($thisfile_ape_items_current['data']);
    281285                                break;
     
    283287                        } elseif (is_string($this->inline_attachments)) {
    284288                            $this->inline_attachments = rtrim(str_replace(array('/', '\\'), DIRECTORY_SEPARATOR, $this->inline_attachments), DIRECTORY_SEPARATOR);
    285                             if (!is_dir($this->inline_attachments) || !is_writable($this->inline_attachments)) {
     289                            if (!is_dir($this->inline_attachments) || !getID3::is_writable($this->inline_attachments)) {
    286290                                // cannot write, skip
    287                                 $info['warning'][] = 'attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$this->inline_attachments.'" (not writable)';
     291                                $this->warning('attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$this->inline_attachments.'" (not writable)');
    288292                                unset($thisfile_ape_items_current['data']);
    289293                                break;
     
    293297                        if (is_string($this->inline_attachments)) {
    294298                            $destination_filename = $this->inline_attachments.DIRECTORY_SEPARATOR.md5($info['filenamepath']).'_'.$thisfile_ape_items_current['data_offset'];
    295                             if (!file_exists($destination_filename) || is_writable($destination_filename)) {
     299                            if (!file_exists($destination_filename) || getID3::is_writable($destination_filename)) {
    296300                                file_put_contents($destination_filename, $thisfile_ape_items_current['data']);
    297301                            } else {
    298                                 $info['warning'][] = 'attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$destination_filename.'" (not writable)';
     302                                $this->warning('attachment at '.$thisfile_ape_items_current['offset'].' cannot be saved to "'.$destination_filename.'" (not writable)');
    299303                            }
    300304                            $thisfile_ape_items_current['data_filename'] = $destination_filename;
Note: See TracChangeset for help on using the changeset viewer.