Make WordPress Core


Ignore:
Timestamp:
07/02/2020 03:46:17 PM (6 years ago)
Author:
desrosj
Message:

External Libraries: Update getID3 to version 1.9.20.

A full list of changes in this update can be found on GitHub: https://github.com/JamesHeinrich/getID3/compare/v1.9.19...v1.9.20.

Props hareesh-pillai, desrosj.
Previously [47601-47604].
Fixes #49945.

File:
1 edited

Legend:

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

    r46586 r48278  
    1515/////////////////////////////////////////////////////////////////
    1616
     17if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers
     18    exit;
     19}
    1720
    1821class getid3_id3v1 extends getid3_handler
     
    6366                $ParsedID3v1['comments'][$key][0] = $value;
    6467            }
    65             // ID3v1 encoding detection hack START
    66             // 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
    67             // 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
    68             $ID3v1encoding = 'ISO-8859-1';
    69             foreach ($ParsedID3v1['comments'] as $tag_key => $valuearray) {
    70                 foreach ($valuearray as $key => $value) {
    71                     if (preg_match('#^[\\x00-\\x40\\xA8\\xB8\\x80-\\xFF]+$#', $value)) {
    72                         foreach (array('Windows-1251', 'KOI8-R') as $id3v1_bad_encoding) {
    73                             if (function_exists('mb_convert_encoding') && @mb_convert_encoding($value, $id3v1_bad_encoding, $id3v1_bad_encoding) === $value) {
    74                                 $ID3v1encoding = $id3v1_bad_encoding;
    75                                 break 3;
    76                             } elseif (function_exists('iconv') && @iconv($id3v1_bad_encoding, $id3v1_bad_encoding, $value) === $value) {
    77                                 $ID3v1encoding = $id3v1_bad_encoding;
    78                                 break 3;
     68            $ID3v1encoding = $this->getid3->encoding_id3v1;
     69            if ($this->getid3->encoding_id3v1_autodetect) {
     70                // ID3v1 encoding detection hack START
     71                // 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
     72                // 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
     73                foreach ($ParsedID3v1['comments'] as $tag_key => $valuearray) {
     74                    foreach ($valuearray as $key => $value) {
     75                        if (preg_match('#^[\\x00-\\x40\\x80-\\xFF]+$#', $value) && !ctype_digit((string) $value)) { // check for strings with only characters above chr(128) and punctuation/numbers, but not just numeric strings (e.g. track numbers or years)
     76                            foreach (array('Windows-1251', 'KOI8-R') as $id3v1_bad_encoding) {
     77                                if (function_exists('mb_convert_encoding') && @mb_convert_encoding($value, $id3v1_bad_encoding, $id3v1_bad_encoding) === $value) {
     78                                    $ID3v1encoding = $id3v1_bad_encoding;
     79                                    $this->warning('ID3v1 detected as '.$id3v1_bad_encoding.' text encoding in '.$tag_key);
     80                                    break 3;
     81                                } elseif (function_exists('iconv') && @iconv($id3v1_bad_encoding, $id3v1_bad_encoding, $value) === $value) {
     82                                    $ID3v1encoding = $id3v1_bad_encoding;
     83                                    $this->warning('ID3v1 detected as '.$id3v1_bad_encoding.' text encoding in '.$tag_key);
     84                                    break 3;
     85                                }
    7986                            }
    8087                        }
    8188                    }
    8289                }
    83             }
    84             // ID3v1 encoding detection hack END
     90                // ID3v1 encoding detection hack END
     91            }
    8592
    8693            // ID3v1 data is supposed to be padded with NULL characters, but some taggers pad with spaces
Note: See TracChangeset for help on using the changeset viewer.