Changeset 48278 for trunk/src/wp-includes/ID3/module.tag.id3v1.php
- Timestamp:
- 07/02/2020 03:46:17 PM (6 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/ID3/module.tag.id3v1.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ID3/module.tag.id3v1.php
r46586 r48278 15 15 ///////////////////////////////////////////////////////////////// 16 16 17 if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers 18 exit; 19 } 17 20 18 21 class getid3_id3v1 extends getid3_handler … … 63 66 $ParsedID3v1['comments'][$key][0] = $value; 64 67 } 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 } 79 86 } 80 87 } 81 88 } 82 89 } 83 }84 // ID3v1 encoding detection hack END90 // ID3v1 encoding detection hack END 91 } 85 92 86 93 // 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.