Make WordPress Core


Ignore:
Timestamp:
09/14/2019 07:06:09 PM (6 years ago)
Author:
jorbin
Message:

Update getID3 library to fix issues with PHP7.4

Updates to trunk version that includes fixes for PHP7.4

Changelog:
https://github.com/JamesHeinrich/getID3/compare/v1.9.14...00f3fbfd77e583099ca70a3cf0bc092e113d2b20

See: #47751,#47783.
Fixes: #48040.

File:
1 edited

Legend:

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

    r41196 r46112  
    11<?php
     2
    23/////////////////////////////////////////////////////////////////
    34/// getID3() by James Heinrich <info@getid3.org>               //
    4 //  available at http://getid3.sourceforge.net                 //
    5 //            or http://www.getid3.org                         //
    6 //          also https://github.com/JamesHeinrich/getID3       //
    7 /////////////////////////////////////////////////////////////////
    8 // See readme.txt for more details                             //
     5//  available at https://github.com/JamesHeinrich/getID3       //
     6//            or https://www.getid3.org                        //
     7//            or http://getid3.sourceforge.net                 //
     8//  see readme.txt for more details                            //
    99/////////////////////////////////////////////////////////////////
    1010//                                                             //
     
    1818class getid3_id3v1 extends getid3_handler
    1919{
    20 
     20    /**
     21     * @return bool
     22     */
    2123    public function Analyze() {
    2224        $info = &$this->getid3->info;
     
    4446            // If second-last byte of comment field is null and last byte of comment field is non-null
    4547            // then this is ID3v1.1 and the comment field is 28 bytes long and the 30th byte is the track number
    46             if (($id3v1tag{125} === "\x00") && ($id3v1tag{126} !== "\x00")) {
    47                 $ParsedID3v1['track']  = ord(substr($ParsedID3v1['comment'], 29,  1));
    48                 $ParsedID3v1['comment'] =     substr($ParsedID3v1['comment'],  0, 28);
     48            if (($id3v1tag[125] === "\x00") && ($id3v1tag[126] !== "\x00")) {
     49                $ParsedID3v1['track_number'] = ord(substr($ParsedID3v1['comment'], 29,  1));
     50                $ParsedID3v1['comment']      =     substr($ParsedID3v1['comment'],  0, 28);
    4951            }
    5052            $ParsedID3v1['comment'] = $this->cutfield($ParsedID3v1['comment']);
     
    6769            foreach ($ParsedID3v1['comments'] as $tag_key => $valuearray) {
    6870                foreach ($valuearray as $key => $value) {
    69                     if (preg_match('#^[\\x00-\\x40\\xA8\\B8\\x80-\\xFF]+$#', $value)) {
     71                    if (preg_match('#^[\\x00-\\x40\\xA8\\xB8\\x80-\\xFF]+$#', $value)) {
    7072                        foreach (array('Windows-1251', 'KOI8-R') as $id3v1_bad_encoding) {
    7173                            if (function_exists('mb_convert_encoding') && @mb_convert_encoding($value, $id3v1_bad_encoding, $id3v1_bad_encoding) === $value) {
     
    9092                                            (isset($ParsedID3v1['genre']) ? $this->LookupGenreID($ParsedID3v1['genre']) : false),
    9193                                            $ParsedID3v1['comment'],
    92                                             (!empty($ParsedID3v1['track']) ? $ParsedID3v1['track'] : ''));
     94                                            (!empty($ParsedID3v1['track_number']) ? $ParsedID3v1['track_number'] : ''));
    9395            $ParsedID3v1['padding_valid'] = true;
    9496            if ($id3v1tag !== $GoodFormatID3v1tag) {
     
    125127    }
    126128
     129    /**
     130     * @param string $str
     131     *
     132     * @return string
     133     */
    127134    public static function cutfield($str) {
    128135        return trim(substr($str, 0, strcspn($str, "\x00")));
    129136    }
    130137
     138    /**
     139     * @param bool $allowSCMPXextended
     140     *
     141     * @return string[]
     142     */
    131143    public static function ArrayOfGenres($allowSCMPXextended=false) {
    132144        static $GenreLookup = array(
     
    313325    }
    314326
     327    /**
     328     * @param string $genreid
     329     * @param bool   $allowSCMPXextended
     330     *
     331     * @return string|false
     332     */
    315333    public static function LookupGenreName($genreid, $allowSCMPXextended=true) {
    316334        switch ($genreid) {
     
    329347    }
    330348
     349    /**
     350     * @param string $genre
     351     * @param bool   $allowSCMPXextended
     352     *
     353     * @return string|false
     354     */
    331355    public static function LookupGenreID($genre, $allowSCMPXextended=false) {
    332356        $GenreLookup = self::ArrayOfGenres($allowSCMPXextended);
     
    340364    }
    341365
     366    /**
     367     * @param string $OriginalGenre
     368     *
     369     * @return string|false
     370     */
    342371    public static function StandardiseID3v1GenreName($OriginalGenre) {
    343372        if (($GenreID = self::LookupGenreID($OriginalGenre)) !== false) {
     
    347376    }
    348377
     378    /**
     379     * @param string     $title
     380     * @param string     $artist
     381     * @param string     $album
     382     * @param string     $year
     383     * @param int        $genreid
     384     * @param string     $comment
     385     * @param int|string $track
     386     *
     387     * @return string
     388     */
    349389    public static function GenerateID3v1Tag($title, $artist, $album, $year, $genreid, $comment, $track='') {
    350390        $ID3v1Tag  = 'TAG';
Note: See TracChangeset for help on using the changeset viewer.