Changeset 41196 for trunk/src/wp-includes/ID3/module.tag.id3v1.php
- Timestamp:
- 07/31/2017 07:49:31 PM (9 years ago)
- File:
-
- 1 edited
-
trunk/src/wp-includes/ID3/module.tag.id3v1.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ID3/module.tag.id3v1.php
r32979 r41196 23 23 24 24 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'); 26 26 return false; 27 27 } … … 61 61 $ParsedID3v1['comments'][$key][0] = $value; 62 62 } 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 63 83 64 84 // ID3v1 data is supposed to be padded with NULL characters, but some taggers pad with spaces … … 74 94 if ($id3v1tag !== $GoodFormatID3v1tag) { 75 95 $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'); 77 97 } 78 98 … … 81 101 82 102 $info['id3v1'] = $ParsedID3v1; 103 $info['id3v1']['encoding'] = $ID3v1encoding; 83 104 } 84 105 … … 96 117 } else { 97 118 // 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'); 99 120 $info['avdataend'] -= 128; 100 121 }
Note: See TracChangeset
for help on using the changeset viewer.