Make WordPress Core


Ignore:
Timestamp:
07/31/2017 07:49:31 PM (9 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.id3v1.php

    r32979 r41196  
    2323
    2424        if (!getid3_lib::intValueSupported($info['filesize'])) {
    25             $info['warning'][] = 'Unable to check for ID3v1 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB';
     25            $this->warning('Unable to check for ID3v1 because file is larger than '.round(PHP_INT_MAX / 1073741824).'GB');
    2626            return false;
    2727        }
     
    6161                $ParsedID3v1['comments'][$key][0] = $value;
    6262            }
     63            // ID3v1 encoding detection hack START
     64            // ID3v1 is defined as always using ISO-8859-1 encoding, but it is not uncommon to find files tagged with ID3v1 using Windows-1251 or other character sets
     65            // Since ID3v1 has no concept of character sets there is no certain way to know we have the correct non-ISO-8859-1 character set, but we can guess
     66            $ID3v1encoding = 'ISO-8859-1';
     67            foreach ($ParsedID3v1['comments'] as $tag_key => $valuearray) {
     68                foreach ($valuearray as $key => $value) {
     69                    if (preg_match('#^[\\x00-\\x40\\xA8\\B8\\x80-\\xFF]+$#', $value)) {
     70                        foreach (array('Windows-1251', 'KOI8-R') as $id3v1_bad_encoding) {
     71                            if (function_exists('mb_convert_encoding') && @mb_convert_encoding($value, $id3v1_bad_encoding, $id3v1_bad_encoding) === $value) {
     72                                $ID3v1encoding = $id3v1_bad_encoding;
     73                                break 3;
     74                            } elseif (function_exists('iconv') && @iconv($id3v1_bad_encoding, $id3v1_bad_encoding, $value) === $value) {
     75                                $ID3v1encoding = $id3v1_bad_encoding;
     76                                break 3;
     77                            }
     78                        }
     79                    }
     80                }
     81            }
     82            // ID3v1 encoding detection hack END
    6383
    6484            // ID3v1 data is supposed to be padded with NULL characters, but some taggers pad with spaces
     
    7494            if ($id3v1tag !== $GoodFormatID3v1tag) {
    7595                $ParsedID3v1['padding_valid'] = false;
    76                 $info['warning'][] = 'Some ID3v1 fields do not use NULL characters for padding';
     96                $this->warning('Some ID3v1 fields do not use NULL characters for padding');
    7797            }
    7898
     
    81101
    82102            $info['id3v1'] = $ParsedID3v1;
     103            $info['id3v1']['encoding'] = $ID3v1encoding;
    83104        }
    84105
     
    96117            } else {
    97118                // APE and Lyrics3 footers not found - assume double ID3v1
    98                 $info['warning'][] = 'Duplicate ID3v1 tag detected - this has been known to happen with iTunes';
     119                $this->warning('Duplicate ID3v1 tag detected - this has been known to happen with iTunes');
    99120                $info['avdataend'] -= 128;
    100121            }
Note: See TracChangeset for help on using the changeset viewer.