Changeset 48278
- Timestamp:
- 07/02/2020 03:46:17 PM (4 years ago)
- Location:
- trunk/src/wp-includes/ID3
- Files:
-
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/ID3/getid3.lib.php
r47737 r48278 682 682 public static function array_max($arraydata, $returnkey=false) { 683 683 $maxvalue = false; 684 $maxkey = false;684 $maxkey = false; 685 685 foreach ($arraydata as $key => $value) { 686 686 if (!is_array($value)) { 687 if ( $value > $maxvalue) {687 if (($maxvalue === false) || ($value > $maxvalue)) { 688 688 $maxvalue = $value; 689 689 $maxkey = $key; … … 702 702 public static function array_min($arraydata, $returnkey=false) { 703 703 $minvalue = false; 704 $minkey = false;704 $minkey = false; 705 705 foreach ($arraydata as $key => $value) { 706 706 if (!is_array($value)) { 707 if ( $value > $minvalue) {707 if (($minvalue === false) || ($value < $minvalue)) { 708 708 $minvalue = $value; 709 709 $minkey = $key; … … 1530 1530 /** 1531 1531 * @param array $ThisFileInfo 1532 * @param bool $option_tags_html default true (just as in the main getID3 class) 1532 1533 * 1533 1534 * @return bool 1534 1535 */ 1535 public static function CopyTagsToComments(&$ThisFileInfo) { 1536 1536 public static function CopyTagsToComments(&$ThisFileInfo, $option_tags_html=true) { 1537 1537 // Copy all entries from ['tags'] into common ['comments'] 1538 1538 if (!empty($ThisFileInfo['tags'])) { 1539 if (isset($ThisFileInfo['tags']['id3v1'])) { 1540 // bubble ID3v1 to the end, if present to aid in detecting bad ID3v1 encodings 1541 $ID3v1 = $ThisFileInfo['tags']['id3v1']; 1542 unset($ThisFileInfo['tags']['id3v1']); 1543 $ThisFileInfo['tags']['id3v1'] = $ID3v1; 1544 unset($ID3v1); 1545 } 1539 1546 foreach ($ThisFileInfo['tags'] as $tagtype => $tagarray) { 1540 1547 foreach ($tagarray as $tagname => $tagdata) { … … 1555 1562 } 1556 1563 } 1564 if (function_exists('mb_convert_encoding')) { 1565 if (trim($value) == trim(substr(mb_convert_encoding($existingvalue, $ThisFileInfo['id3v1']['encoding'], $ThisFileInfo['encoding']), 0, 30))) { 1566 // value stored in ID3v1 appears to be probably the multibyte value transliterated (badly) into ISO-8859-1 in ID3v1. 1567 // As an example, Foobar2000 will do this if you tag a file with Chinese or Arabic or Cyrillic or something that doesn't fit into ISO-8859-1 the ID3v1 will consist of mostly "?" characters, one per multibyte unrepresentable character 1568 break 2; 1569 } 1570 } 1557 1571 1558 1572 } elseif (!is_array($value)) { … … 1563 1577 if ((strlen($existingvalue) > 10) && ($newvaluelength > $oldvaluelength) && (substr(trim($value), 0, strlen($existingvalue)) == $existingvalue)) { 1564 1578 $ThisFileInfo['comments'][$tagname][$existingkey] = trim($value); 1565 //break 2;1566 1579 break; 1567 1580 } … … 1598 1611 } 1599 1612 1600 // Copy to ['comments_html'] 1601 if (!empty($ThisFileInfo['comments'])) { 1602 foreach ($ThisFileInfo['comments'] as $field => $values) { 1603 if ($field == 'picture') { 1604 // pictures can take up a lot of space, and we don't need multiple copies of them 1605 // let there be a single copy in [comments][picture], and not elsewhere 1606 continue; 1607 } 1608 foreach ($values as $index => $value) { 1609 if (is_array($value)) { 1610 $ThisFileInfo['comments_html'][$field][$index] = $value; 1611 } else { 1612 $ThisFileInfo['comments_html'][$field][$index] = str_replace('�', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding'])); 1613 if ($option_tags_html) { 1614 // Copy ['comments'] to ['comments_html'] 1615 if (!empty($ThisFileInfo['comments'])) { 1616 foreach ($ThisFileInfo['comments'] as $field => $values) { 1617 if ($field == 'picture') { 1618 // pictures can take up a lot of space, and we don't need multiple copies of them 1619 // let there be a single copy in [comments][picture], and not elsewhere 1620 continue; 1621 } 1622 foreach ($values as $index => $value) { 1623 if (is_array($value)) { 1624 $ThisFileInfo['comments_html'][$field][$index] = $value; 1625 } else { 1626 $ThisFileInfo['comments_html'][$field][$index] = str_replace('�', '', self::MultiByteCharString2HTML($value, $ThisFileInfo['encoding'])); 1627 } 1613 1628 } 1614 1629 } -
trunk/src/wp-includes/ID3/getid3.php
r47737 r48278 100 100 public $encoding_id3v1 = 'ISO-8859-1'; 101 101 102 /** 103 * ID3v1 should always be 'ISO-8859-1', but some tags may be written in other encodings such as 'Windows-1251' or 'KOI8-R'. If true attempt to detect these encodings, but may return incorrect values for some tags actually in ISO-8859-1 encoding 104 * 105 * @var bool 106 */ 107 public $encoding_id3v1_autodetect = false; 108 102 109 /* 103 110 * Optional tag checks - disable for speed. … … 251 258 protected $startup_warning = ''; 252 259 253 const VERSION = '1.9. 19-201912211559';260 const VERSION = '1.9.20-202006061653'; 254 261 const FREAD_BUFFER_SIZE = 32768; 255 262 … … 290 297 } 291 298 292 if (($mbstring_func_overload = (int) ini_get('mbstring.func_overload')) && ($mbstring_func_overload & 0x02)) { // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated 299 // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated 300 if (($mbstring_func_overload = (int) ini_get('mbstring.func_overload')) && ($mbstring_func_overload & 0x02)) { 293 301 // http://php.net/manual/en/mbstring.overload.php 294 302 // "mbstring.func_overload in php.ini is a positive value that represents a combination of bitmasks specifying the categories of functions to be overloaded. It should be set to 1 to overload the mail() function. 2 for string functions, 4 for regular expression functions" 295 303 // getID3 cannot run when string functions are overloaded. It doesn't matter if mail() or ereg* functions are overloaded since getID3 does not use those. 296 $this->startup_error .= 'WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", getID3 cannot run with this setting (bitmask 2 (string functions) cannot be set). Recommended to disable entirely.'."\n"; // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated 304 // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.mbstring_func_overloadDeprecated 305 $this->startup_error .= 'WARNING: php.ini contains "mbstring.func_overload = '.ini_get('mbstring.func_overload').'", getID3 cannot run with this setting (bitmask 2 (string functions) cannot be set). Recommended to disable entirely.'."\n"; 297 306 } 298 307 … … 301 310 // Check for magic_quotes_runtime 302 311 if (function_exists('get_magic_quotes_runtime')) { 303 if (get_magic_quotes_runtime()) { // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_runtimeDeprecated 312 // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_runtimeDeprecated 313 if (get_magic_quotes_runtime()) { 304 314 $this->startup_error .= 'magic_quotes_runtime must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_runtime(0) and set_magic_quotes_runtime(1).'."\n"; 305 315 } … … 307 317 // Check for magic_quotes_gpc 308 318 if (function_exists('get_magic_quotes_gpc')) { 309 if (get_magic_quotes_gpc()) { // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_gpcDeprecated 319 // phpcs:ignore PHPCompatibility.FunctionUse.RemovedFunctions.get_magic_quotes_gpcDeprecated 320 if (get_magic_quotes_gpc()) { 310 321 $this->startup_error .= 'magic_quotes_gpc must be disabled before running getID3(). Surround getid3 block by set_magic_quotes_gpc(0) and set_magic_quotes_gpc(1).'."\n"; 311 322 } … … 847 858 ), 848 859 860 // DSDIFF - audio - Direct Stream Digital Interchange File Format 861 'dsdiff' => array( 862 'pattern' => '^FRM8', 863 'group' => 'audio', 864 'module' => 'dsdiff', 865 'mime_type' => 'audio/dsd', 866 ), 867 849 868 // DTS - audio - Dolby Theatre System 850 869 'dts' => array( … … 974 993 ), 975 994 995 // TAK - audio - Tom's lossless Audio Kompressor 996 'tak' => array( 997 'pattern' => '^tBaK', 998 'group' => 'audio', 999 'module' => 'tak', 1000 'mime_type' => 'application/octet-stream', 1001 ), 1002 976 1003 // TTA - audio - TTA Lossless Audio Compressor (http://tta.corecodec.org) 977 1004 'tta' => array( … … 1032 1059 'module' => 'flv', 1033 1060 'mime_type' => 'video/x-flv', 1061 ), 1062 1063 // IVF - audio/video - IVF 1064 'ivf' => array( 1065 'pattern' => '^DKIF', 1066 'group' => 'audio-video', 1067 'module' => 'ivf', 1068 'mime_type' => 'video/x-ivf', 1034 1069 ), 1035 1070 … … 1218 1253 ), 1219 1254 1255 // HPK - data - HPK compressed data 1256 'hpk' => array( 1257 'pattern' => '^BPUL', 1258 'group' => 'archive', 1259 'module' => 'hpk', 1260 'mime_type' => 'application/octet-stream', 1261 'fail_id3' => 'ERROR', 1262 'fail_ape' => 'ERROR', 1263 ), 1264 1220 1265 // RAR - data - RAR compressed data 1221 1266 'rar' => array( … … 1223 1268 'group' => 'archive', 1224 1269 'module' => 'rar', 1225 'mime_type' => 'application/ octet-stream',1270 'mime_type' => 'application/vnd.rar', 1226 1271 'fail_id3' => 'ERROR', 1227 1272 'fail_ape' => 'ERROR', … … 1425 1470 'divxtag' => array('divx' , 'ISO-8859-1'), 1426 1471 'iptc' => array('iptc' , 'ISO-8859-1'), 1472 'dsdiff' => array('dsdiff' , 'ISO-8859-1'), 1427 1473 ); 1428 1474 } … … 1527 1573 1528 1574 /** 1575 * Calls getid3_lib::CopyTagsToComments() but passes in the option_tags_html setting from this instance of getID3 1576 * 1577 * @param array $ThisFileInfo 1578 * 1579 * @return bool 1580 */ 1581 public function CopyTagsToComments(&$ThisFileInfo) { 1582 return getid3_lib::CopyTagsToComments($ThisFileInfo, $this->option_tags_html); 1583 } 1584 1585 /** 1529 1586 * @param string $algorithm 1530 1587 * … … 1561 1618 // currently vorbiscomment only works on OggVorbis files. 1562 1619 1563 if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) { // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.safe_modeDeprecatedRemoved 1620 // phpcs:ignore PHPCompatibility.IniDirectives.RemovedIniDirectives.safe_modeDeprecatedRemoved 1621 if (preg_match('#(1|ON)#i', ini_get('safe_mode'))) { 1564 1622 1565 1623 $this->warning('Failed making system call to vorbiscomment.exe - '.$algorithm.'_data is incorrect - error returned: PHP running in Safe Mode (backtick operator not available)'); … … 2055 2113 2056 2114 /** 2115 * @return string|false 2116 * 2117 * @throws getid3_exception 2118 */ 2119 protected function fgets() { 2120 // must be able to handle CR/LF/CRLF but not read more than one lineend 2121 $buffer = ''; // final string we will return 2122 $prevchar = ''; // save previously-read character for end-of-line checking 2123 if ($this->data_string_flag) { 2124 while (true) { 2125 $thischar = substr($this->data_string, $this->data_string_position++, 1); 2126 if (($prevchar == "\r") && ($thischar != "\n")) { 2127 // read one byte too many, back up 2128 $this->data_string_position--; 2129 break; 2130 } 2131 $buffer .= $thischar; 2132 if ($thischar == "\n") { 2133 break; 2134 } 2135 if ($this->data_string_position >= $this->data_string_length) { 2136 // EOF 2137 break; 2138 } 2139 $prevchar = $thischar; 2140 } 2141 2142 } else { 2143 2144 // Ideally we would just use PHP's fgets() function, however... 2145 // it does not behave consistently with regards to mixed line endings, may be system-dependent 2146 // and breaks entirely when given a file with mixed \r vs \n vs \r\n line endings (e.g. some PDFs) 2147 //return fgets($this->getid3->fp); 2148 while (true) { 2149 $thischar = fgetc($this->getid3->fp); 2150 if (($prevchar == "\r") && ($thischar != "\n")) { 2151 // read one byte too many, back up 2152 fseek($this->getid3->fp, -1, SEEK_CUR); 2153 break; 2154 } 2155 $buffer .= $thischar; 2156 if ($thischar == "\n") { 2157 break; 2158 } 2159 if (feof($this->getid3->fp)) { 2160 break; 2161 } 2162 $prevchar = $thischar; 2163 } 2164 2165 } 2166 return $buffer; 2167 } 2168 2169 /** 2057 2170 * @return bool 2058 2171 */ -
trunk/src/wp-includes/ID3/module.audio-video.asf.php
r47601 r48278 14 14 ///////////////////////////////////////////////////////////////// 15 15 16 if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers 17 exit; 18 } 16 19 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio-video.riff.php', __FILE__, true); 17 20 -
trunk/src/wp-includes/ID3/module.audio-video.flv.php
r47601 r48278 53 53 // /// 54 54 ///////////////////////////////////////////////////////////////// 55 56 if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers 57 exit; 58 } 55 59 56 60 define('GETID3_FLV_TAG_AUDIO', 8); -
trunk/src/wp-includes/ID3/module.audio-video.matroska.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 define('EBML_ID_CHAPTERS', 0x0043A770); // [10][43][A7][70] -- A system to define basic menus and partition data. For more detailed information, look at the Chapters Explanation. … … 330 333 } 331 334 332 $info['video']['streams'][ ] = $track_info;335 $info['video']['streams'][$trackarray['TrackUID']] = $track_info; 333 336 break; 334 337 … … 363 366 $getid3_temp = new getID3(); 364 367 if ($track_info['dataformat'] != 'flac') { 365 $getid3_temp->openfile($this->getid3->filename );368 $getid3_temp->openfile($this->getid3->filename, $this->getid3->info['filesize'], $this->getid3->fp); 366 369 } 367 370 $getid3_temp->info['avdataoffset'] = $info['matroska']['track_data_offsets'][$trackarray['TrackNumber']]['offset']; … … 479 482 } 480 483 481 $info['audio']['streams'][ ] = $track_info;484 $info['audio']['streams'][$trackarray['TrackUID']] = $track_info; 482 485 break; 483 486 } … … 508 511 } elseif (isset($info['mime_type'])) { 509 512 unset($info['mime_type']); 513 } 514 515 // use _STATISTICS_TAGS if available to set audio/video bitrates 516 if (!empty($info['matroska']['tags'])) { 517 $_STATISTICS_byTrackUID = array(); 518 foreach ($info['matroska']['tags'] as $key1 => $value1) { 519 if (!empty($value1['Targets']['TagTrackUID'][0]) && !empty($value1['SimpleTag'])) { 520 foreach ($value1['SimpleTag'] as $key2 => $value2) { 521 if (!empty($value2['TagName']) && isset($value2['TagString'])) { 522 $_STATISTICS_byTrackUID[$value1['Targets']['TagTrackUID'][0]][$value2['TagName']] = $value2['TagString']; 523 } 524 } 525 } 526 } 527 foreach (array('audio','video') as $avtype) { 528 if (!empty($info[$avtype]['streams'])) { 529 foreach ($info[$avtype]['streams'] as $trackUID => $trackdata) { 530 if (!isset($trackdata['bitrate']) && !empty($_STATISTICS_byTrackUID[$trackUID]['BPS'])) { 531 $info[$avtype]['streams'][$trackUID]['bitrate'] = (int) $_STATISTICS_byTrackUID[$trackUID]['BPS']; 532 @$info[$avtype]['bitrate'] += $info[$avtype]['streams'][$trackUID]['bitrate']; 533 } 534 } 535 } 536 } 510 537 } 511 538 … … 615 642 switch ($subelement['id']) { 616 643 644 case EBML_ID_TRACKUID: 645 $track_entry[$subelement['id_name']] = getid3_lib::PrintHexBytes($subelement['data'], true, false); 646 break; 617 647 case EBML_ID_TRACKNUMBER: 618 case EBML_ID_TRACKUID:619 648 case EBML_ID_TRACKTYPE: 620 649 case EBML_ID_MINCACHE: … … 964 993 case EBML_ID_TAGCHAPTERUID: 965 994 case EBML_ID_TAGATTACHMENTUID: 966 $targets_entry[$sub_sub_subelement['id_name']][] = getid3_lib:: BigEndian2Int($sub_sub_subelement['data']);995 $targets_entry[$sub_sub_subelement['id_name']][] = getid3_lib::PrintHexBytes($sub_sub_subelement['data'], true, false); 967 996 break; 968 997 -
trunk/src/wp-includes/ID3/module.audio-video.quicktime.php
r47902 r48278 16 16 ///////////////////////////////////////////////////////////////// 17 17 18 if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers 19 exit; 20 } 18 21 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true); 19 22 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v2.php', __FILE__, true); // needed for ISO 639-2 language code lookup … … 56 59 } 57 60 58 $info['quicktime'][$atomname]['name'] = $atomname;59 $info['quicktime'][$atomname]['size'] = $atomsize;60 $info['quicktime'][$atomname]['offset'] = $offset;61 62 61 if (($offset + $atomsize) > $info['avdataend']) { 62 $info['quicktime'][$atomname]['name'] = $atomname; 63 $info['quicktime'][$atomname]['size'] = $atomsize; 64 $info['quicktime'][$atomname]['offset'] = $offset; 63 65 $this->error('Atom at offset '.$offset.' claims to go beyond end-of-file (length: '.$atomsize.' bytes)'); 64 66 return false; 65 67 } 66 67 68 if ($atomsize == 0) { 68 69 // Furthermore, for historical reasons the list of atoms is optionally 69 70 // terminated by a 32-bit integer set to 0. If you are writing a program 70 71 // to read user data atoms, you should allow for the terminating 0. 72 $info['quicktime'][$atomname]['name'] = $atomname; 73 $info['quicktime'][$atomname]['size'] = $atomsize; 74 $info['quicktime'][$atomname]['offset'] = $offset; 71 75 break; 72 76 } 77 73 78 $atomHierarchy = array(); 74 $info['quicktime'][$atomname] = $this->QuicktimeParseAtom($atomname, $atomsize, $this->fread(min($atomsize, $atom_data_read_buffer_size)), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms); 79 $parsedAtomData = $this->QuicktimeParseAtom($atomname, $atomsize, $this->fread(min($atomsize, $atom_data_read_buffer_size)), $offset, $atomHierarchy, $this->ParseAllPossibleAtoms); 80 $parsedAtomData['name'] = $atomname; 81 $parsedAtomData['size'] = $atomsize; 82 $parsedAtomData['offset'] = $offset; 83 if (in_array($atomname, array('uuid'))) { 84 @$info['quicktime'][$atomname][] = $parsedAtomData; 85 } else { 86 $info['quicktime'][$atomname] = $parsedAtomData; 87 } 75 88 76 89 $offset += $atomsize; … … 115 128 $ISO6709parsed = array('latitude'=>false, 'longitude'=>false, 'altitude'=>false); 116 129 if (preg_match('#^([\\+\\-])([0-9]{2}|[0-9]{4}|[0-9]{6})(\\.[0-9]+)?([\\+\\-])([0-9]{3}|[0-9]{5}|[0-9]{7})(\\.[0-9]+)?(([\\+\\-])([0-9]{3}|[0-9]{5}|[0-9]{7})(\\.[0-9]+)?)?/$#', $ISO6709string, $matches)) { 117 @list($dummy, $lat_sign, $lat_deg, $lat_deg_dec, $lon_sign, $lon_deg, $lon_deg_dec, $dummy, $alt_sign, $alt_deg, $alt_deg_dec) = $matches; // phpcs:ignore PHPCompatibility.Lists.AssignmentOrder.Affected 130 // phpcs:ignore PHPCompatibility.Lists.AssignmentOrder.Affected 131 @list($dummy, $lat_sign, $lat_deg, $lat_deg_dec, $lon_sign, $lon_deg, $lon_deg_dec, $dummy, $alt_sign, $alt_deg, $alt_deg_dec) = $matches; 118 132 119 133 if (strlen($lat_deg) == 2) { // [+-]DD.D … … 144 158 if ($ISO6709parsed[$key] !== false) { 145 159 $value = (($lat_sign == '-') ? -1 : 1) * floatval($ISO6709parsed[$key]); 146 if (!i n_array($value, $info['quicktime']['comments']['gps_'.$key])) {147 $info['quicktime']['comments']['gps_'.$key][]= (($lat_sign == '-') ? -1 : 1) * floatval($ISO6709parsed[$key]);160 if (!isset($info['quicktime']['comments']['gps_'.$key]) || !in_array($value, $info['quicktime']['comments']['gps_'.$key])) { 161 @$info['quicktime']['comments']['gps_'.$key][] = (($lat_sign == '-') ? -1 : 1) * floatval($ISO6709parsed[$key]); 148 162 } 149 163 } … … 528 542 $atom_structure['image_mime'] = 'image/gif'; 529 543 } 544 $info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_structure['data'], 'description'=>'cover'); 530 545 break; 531 546 … … 554 569 $atom_structure['image_mime'] = 'image/gif'; 555 570 } 571 $info['quicktime']['comments']['picture'][] = array('image_mime'=>$atom_structure['image_mime'], 'data'=>$atom_structure['data'], 'description'=>'cover'); 556 572 } 557 573 break; … … 756 772 $atom_structure['sample_description_table'][$i]['data'] = substr($atom_data, $stsdEntriesDataOffset, ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2)); 757 773 $stsdEntriesDataOffset += ($atom_structure['sample_description_table'][$i]['size'] - 4 - 4 - 6 - 2); 774 775 if (substr($atom_structure['sample_description_table'][$i]['data'], 1, 54) == 'application/octet-stream;type=com.parrot.videometadata') { 776 // special handling for apparently-malformed (TextMetaDataSampleEntry?) data for some version of Parrot drones 777 $atom_structure['sample_description_table'][$i]['parrot_frame_metadata']['mime_type'] = substr($atom_structure['sample_description_table'][$i]['data'], 1, 55); 778 $atom_structure['sample_description_table'][$i]['parrot_frame_metadata']['metadata_version'] = (int) substr($atom_structure['sample_description_table'][$i]['data'], 55, 1); 779 unset($atom_structure['sample_description_table'][$i]['data']); 780 $this->warning('incomplete/incorrect handling of "stsd" with Parrot metadata in this version of getID3() ['.$this->getid3->version().']'); 781 continue; 782 } 758 783 759 784 $atom_structure['sample_description_table'][$i]['encoder_version'] = getid3_lib::BigEndian2Int(substr($atom_structure['sample_description_table'][$i]['data'], 0, 2)); … … 1134 1159 $atom_structure['component_flags_raw'] = getid3_lib::BigEndian2Int(substr($atom_data, 16, 4)); 1135 1160 $atom_structure['component_flags_mask'] = getid3_lib::BigEndian2Int(substr($atom_data, 20, 4)); 1136 $atom_structure['component_name'] = $this->Pascal2String(substr($atom_data, 24));1161 $atom_structure['component_name'] = $this->MaybePascal2String(substr($atom_data, 24)); 1137 1162 1138 1163 if (($atom_structure['component_subtype'] == 'STpn') && ($atom_structure['component_manufacturer'] == 'zzzz')) { … … 1165 1190 $info['comments']['language'][] = $atom_structure['language']; 1166 1191 } 1192 $info['quicktime']['timestamps_unix']['create'][$atom_structure['hierarchy']] = $atom_structure['creation_time_unix']; 1193 $info['quicktime']['timestamps_unix']['modify'][$atom_structure['hierarchy']] = $atom_structure['modify_time_unix']; 1167 1194 break; 1168 1195 … … 1175 1202 1176 1203 $atom_structure['modification_date_unix'] = getid3_lib::DateMac2Unix($atom_structure['modification_date']); 1204 $info['quicktime']['timestamps_unix']['modify'][$atom_structure['hierarchy']] = $atom_structure['modification_date_unix']; 1177 1205 break; 1178 1206 … … 1272 1300 $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']); 1273 1301 $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']); 1302 $info['quicktime']['timestamps_unix']['create'][$atom_structure['hierarchy']] = $atom_structure['creation_time_unix']; 1303 $info['quicktime']['timestamps_unix']['modify'][$atom_structure['hierarchy']] = $atom_structure['modify_time_unix']; 1274 1304 $info['quicktime']['time_scale'] = ((isset($info['quicktime']['time_scale']) && ($info['quicktime']['time_scale'] < 1000)) ? max($info['quicktime']['time_scale'], $atom_structure['time_scale']) : $atom_structure['time_scale']); 1275 1305 $info['quicktime']['display_scale'] = $atom_structure['matrix_a']; … … 1310 1340 $atom_structure['creation_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['creation_time']); 1311 1341 $atom_structure['modify_time_unix'] = getid3_lib::DateMac2Unix($atom_structure['modify_time']); 1342 $info['quicktime']['timestamps_unix']['create'][$atom_structure['hierarchy']] = $atom_structure['creation_time_unix']; 1343 $info['quicktime']['timestamps_unix']['modify'][$atom_structure['hierarchy']] = $atom_structure['modify_time_unix']; 1312 1344 1313 1345 // https://www.getid3.org/phpBB3/viewtopic.php?t=1908 … … 1451 1483 1452 1484 $getid3_temp = new getID3(); 1453 $getid3_temp->openfile($this->getid3->filename );1485 $getid3_temp->openfile($this->getid3->filename, $this->getid3->info['filesize'], $this->getid3->fp); 1454 1486 $getid3_temp->info['avdataoffset'] = $info['avdataoffset']; 1455 1487 $getid3_temp->info['avdataend'] = $info['avdataend']; … … 1640 1672 break; 1641 1673 1642 case 'uuid': // Atom holding 360fly spatial data?? 1643 /* code in this block by Paul Lewis 2019-Oct-31 */ 1644 /* Sensor Timestamps need to be calculated using the recordings base time at ['quicktime']['moov']['subatoms'][0]['creation_time_unix']. */ 1645 $atom_structure['title'] = '360Fly Sensor Data'; 1646 1674 case 'uuid': // user-defined atom often seen containing XML data, also used for potentially many other purposes, only a few specifically handled by getID3 (e.g. 360fly spatial data) 1647 1675 //Get the UUID ID in first 16 bytes 1648 1676 $uuid_bytes_read = unpack('H8time_low/H4time_mid/H4time_hi/H4clock_seq_hi/H12clock_seq_low', substr($atom_data, 0, 16)); 1649 $atom_structure['uuid_field_id'] = print_r(implode('-', $uuid_bytes_read), true); 1650 1651 //Get the UUID HEADER data 1652 $uuid_bytes_read = unpack('Sheader_size/Sheader_version/Stimescale/Shardware_version/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x/', substr($atom_data, 16, 32)); 1653 $atom_structure['uuid_header'] = json_encode($uuid_bytes_read, true); 1654 1655 $start_byte = 48; 1656 $atom_SENSOR_data = substr($atom_data, $start_byte); 1657 $atom_structure['sensor_data']['data_type'] = array( 1658 'fusion_count' => 0, // ID 250 1659 'fusion_data' => array(), 1660 'accel_count' => 0, // ID 1 1661 'accel_data' => array(), 1662 'gyro_count' => 0, // ID 2 1663 'gyro_data' => array(), 1664 'magno_count' => 0, // ID 3 1665 'magno_data' => array(), 1666 'gps_count' => 0, // ID 5 1667 'gps_data' => array(), 1668 'rotation_count' => 0, // ID 6 1669 'rotation_data' => array(), 1670 'unknown_count' => 0, // ID ?? 1671 'unknown_data' => array(), 1672 'debug_list' => '', // Used to debug variables stored as comma delimited strings 1673 ); 1674 $debug_structure['debug_items'] = array(); 1675 // Can start loop here to decode all sensor data in 32 Byte chunks: 1676 foreach (str_split($atom_SENSOR_data, 32) as $sensor_key => $sensor_data) { 1677 // This gets me a data_type code to work out what data is in the next 31 bytes. 1678 $sensor_data_type = substr($sensor_data, 0, 1); 1679 $sensor_data_content = substr($sensor_data, 1); 1680 $uuid_bytes_read = unpack('C*', $sensor_data_type); 1681 $sensor_data_array = array(); 1682 switch ($uuid_bytes_read[1]) { 1683 case 250: 1684 $atom_structure['sensor_data']['data_type']['fusion_count']++; 1685 $uuid_bytes_read = unpack('cmode/Jtimestamp/Gyaw/Gpitch/Groll/x*', $sensor_data_content); 1686 $sensor_data_array['mode'] = $uuid_bytes_read['mode']; 1687 $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp']; 1688 $sensor_data_array['yaw'] = $uuid_bytes_read['yaw']; 1689 $sensor_data_array['pitch'] = $uuid_bytes_read['pitch']; 1690 $sensor_data_array['roll'] = $uuid_bytes_read['roll']; 1691 array_push($atom_structure['sensor_data']['data_type']['fusion_data'], $sensor_data_array); 1692 break; 1693 case 1: 1694 $atom_structure['sensor_data']['data_type']['accel_count']++; 1695 $uuid_bytes_read = unpack('cmode/Jtimestamp/Gyaw/Gpitch/Groll/x*', $sensor_data_content); 1696 $sensor_data_array['mode'] = $uuid_bytes_read['mode']; 1697 $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp']; 1698 $sensor_data_array['yaw'] = $uuid_bytes_read['yaw']; 1699 $sensor_data_array['pitch'] = $uuid_bytes_read['pitch']; 1700 $sensor_data_array['roll'] = $uuid_bytes_read['roll']; 1701 array_push($atom_structure['sensor_data']['data_type']['accel_data'], $sensor_data_array); 1702 break; 1703 case 2: 1704 $atom_structure['sensor_data']['data_type']['gyro_count']++; 1705 $uuid_bytes_read = unpack('cmode/Jtimestamp/Gyaw/Gpitch/Groll/x*', $sensor_data_content); 1706 $sensor_data_array['mode'] = $uuid_bytes_read['mode']; 1707 $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp']; 1708 $sensor_data_array['yaw'] = $uuid_bytes_read['yaw']; 1709 $sensor_data_array['pitch'] = $uuid_bytes_read['pitch']; 1710 $sensor_data_array['roll'] = $uuid_bytes_read['roll']; 1711 array_push($atom_structure['sensor_data']['data_type']['gyro_data'], $sensor_data_array); 1712 break; 1713 case 3: 1714 $atom_structure['sensor_data']['data_type']['magno_count']++; 1715 $uuid_bytes_read = unpack('cmode/Jtimestamp/Gmagx/Gmagy/Gmagz/x*', $sensor_data_content); 1716 $sensor_data_array['mode'] = $uuid_bytes_read['mode']; 1717 $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp']; 1718 $sensor_data_array['magx'] = $uuid_bytes_read['magx']; 1719 $sensor_data_array['magy'] = $uuid_bytes_read['magy']; 1720 $sensor_data_array['magz'] = $uuid_bytes_read['magz']; 1721 array_push($atom_structure['sensor_data']['data_type']['magno_data'], $sensor_data_array); 1722 break; 1723 case 5: 1724 $atom_structure['sensor_data']['data_type']['gps_count']++; 1725 $uuid_bytes_read = unpack('cmode/Jtimestamp/Glat/Glon/Galt/Gspeed/nbearing/nacc/x*', $sensor_data_content); 1726 $sensor_data_array['mode'] = $uuid_bytes_read['mode']; 1727 $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp']; 1728 $sensor_data_array['lat'] = $uuid_bytes_read['lat']; 1729 $sensor_data_array['lon'] = $uuid_bytes_read['lon']; 1730 $sensor_data_array['alt'] = $uuid_bytes_read['alt']; 1731 $sensor_data_array['speed'] = $uuid_bytes_read['speed']; 1732 $sensor_data_array['bearing'] = $uuid_bytes_read['bearing']; 1733 $sensor_data_array['acc'] = $uuid_bytes_read['acc']; 1734 //$sensor_data_array = print_r($uuid_bytes_read, true); 1735 array_push($atom_structure['sensor_data']['data_type']['gps_data'], $sensor_data_array); 1736 //array_push($debug_structure['debug_items'], $uuid_bytes_read['timestamp']); 1737 break; 1738 case 6: 1739 $atom_structure['sensor_data']['data_type']['rotation_count']++; 1740 $uuid_bytes_read = unpack('cmode/Jtimestamp/Grotx/Groty/Grotz/x*', $sensor_data_content); 1741 $sensor_data_array['mode'] = $uuid_bytes_read['mode']; 1742 $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp']; 1743 $sensor_data_array['rotx'] = $uuid_bytes_read['rotx']; 1744 $sensor_data_array['roty'] = $uuid_bytes_read['roty']; 1745 $sensor_data_array['rotz'] = $uuid_bytes_read['rotz']; 1746 array_push($atom_structure['sensor_data']['data_type']['rotation_data'], $sensor_data_array); 1747 break; 1748 default: 1749 $atom_structure['sensor_data']['data_type']['unknown_count']++; 1750 break; 1751 } 1752 } 1753 // if (isset($debug_structure['debug_items']) && count($debug_structure['debug_items']) > 0) { 1754 // $atom_structure['sensor_data']['data_type']['debug_list'] = implode(',', $debug_structure['debug_items']); 1755 // } else { 1756 $atom_structure['sensor_data']['data_type']['debug_list'] = 'No debug items in list!'; 1757 // } 1677 $atom_structure['uuid_field_id'] = implode('-', $uuid_bytes_read); 1678 1679 switch ($atom_structure['uuid_field_id']) { // http://fileformats.archiveteam.org/wiki/Boxes/atoms_format#UUID_boxes 1680 1681 case '0537cdab-9d0c-4431-a72a-fa561f2a113e': // Exif - http://fileformats.archiveteam.org/wiki/Exif 1682 case '2c4c0100-8504-40b9-a03e-562148d6dfeb': // Photoshop Image Resources - http://fileformats.archiveteam.org/wiki/Photoshop_Image_Resources 1683 case '33c7a4d2-b81d-4723-a0ba-f1a3e097ad38': // IPTC-IIM - http://fileformats.archiveteam.org/wiki/IPTC-IIM 1684 case '8974dbce-7be7-4c51-84f9-7148f9882554': // PIFF Track Encryption Box - http://fileformats.archiveteam.org/wiki/Protected_Interoperable_File_Format 1685 case '96a9f1f1-dc98-402d-a7ae-d68e34451809': // GeoJP2 World File Box - http://fileformats.archiveteam.org/wiki/GeoJP2 1686 case 'a2394f52-5a9b-4f14-a244-6c427c648df4': // PIFF Sample Encryption Box - http://fileformats.archiveteam.org/wiki/Protected_Interoperable_File_Format 1687 case 'b14bf8bd-083d-4b43-a5ae-8cd7d5a6ce03': // GeoJP2 GeoTIFF Box - http://fileformats.archiveteam.org/wiki/GeoJP2 1688 case 'd08a4f18-10f3-4a82-b6c8-32d8aba183d3': // PIFF Protection System Specific Header Box - http://fileformats.archiveteam.org/wiki/Protected_Interoperable_File_Format 1689 $this->warning('Unhandled (but recognized) "uuid" atom identified by "'.$atom_structure['uuid_field_id'].'" at offset '.$atom_structure['offset'].' ('.strlen($atom_data).' bytes)'); 1690 break; 1691 1692 case 'be7acfcb-97a9-42e8-9c71-999491e3afac': // XMP data (in XML format) 1693 $atom_structure['xml'] = substr($atom_data, 16, strlen($atom_data) - 16 - 8); // 16 bytes for UUID, 8 bytes header(?) 1694 break; 1695 1696 case 'efe1589a-bb77-49ef-8095-27759eb1dc6f': // 360fly data 1697 /* 360fly code in this block by Paul Lewis 2019-Oct-31 */ 1698 /* Sensor Timestamps need to be calculated using the recordings base time at ['quicktime']['moov']['subatoms'][0]['creation_time_unix']. */ 1699 $atom_structure['title'] = '360Fly Sensor Data'; 1700 1701 //Get the UUID HEADER data 1702 $uuid_bytes_read = unpack('vheader_size/vheader_version/vtimescale/vhardware_version/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x/x/', substr($atom_data, 16, 32)); 1703 $atom_structure['uuid_header'] = $uuid_bytes_read; 1704 1705 $start_byte = 48; 1706 $atom_SENSOR_data = substr($atom_data, $start_byte); 1707 $atom_structure['sensor_data']['data_type'] = array( 1708 'fusion_count' => 0, // ID 250 1709 'fusion_data' => array(), 1710 'accel_count' => 0, // ID 1 1711 'accel_data' => array(), 1712 'gyro_count' => 0, // ID 2 1713 'gyro_data' => array(), 1714 'magno_count' => 0, // ID 3 1715 'magno_data' => array(), 1716 'gps_count' => 0, // ID 5 1717 'gps_data' => array(), 1718 'rotation_count' => 0, // ID 6 1719 'rotation_data' => array(), 1720 'unknown_count' => 0, // ID ?? 1721 'unknown_data' => array(), 1722 'debug_list' => '', // Used to debug variables stored as comma delimited strings 1723 ); 1724 $debug_structure['debug_items'] = array(); 1725 // Can start loop here to decode all sensor data in 32 Byte chunks: 1726 foreach (str_split($atom_SENSOR_data, 32) as $sensor_key => $sensor_data) { 1727 // This gets me a data_type code to work out what data is in the next 31 bytes. 1728 $sensor_data_type = substr($sensor_data, 0, 1); 1729 $sensor_data_content = substr($sensor_data, 1); 1730 $uuid_bytes_read = unpack('C*', $sensor_data_type); 1731 $sensor_data_array = array(); 1732 switch ($uuid_bytes_read[1]) { 1733 case 250: 1734 $atom_structure['sensor_data']['data_type']['fusion_count']++; 1735 $uuid_bytes_read = unpack('cmode/Jtimestamp/Gyaw/Gpitch/Groll/x*', $sensor_data_content); 1736 $sensor_data_array['mode'] = $uuid_bytes_read['mode']; 1737 $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp']; 1738 $sensor_data_array['yaw'] = $uuid_bytes_read['yaw']; 1739 $sensor_data_array['pitch'] = $uuid_bytes_read['pitch']; 1740 $sensor_data_array['roll'] = $uuid_bytes_read['roll']; 1741 array_push($atom_structure['sensor_data']['data_type']['fusion_data'], $sensor_data_array); 1742 break; 1743 case 1: 1744 $atom_structure['sensor_data']['data_type']['accel_count']++; 1745 $uuid_bytes_read = unpack('cmode/Jtimestamp/Gyaw/Gpitch/Groll/x*', $sensor_data_content); 1746 $sensor_data_array['mode'] = $uuid_bytes_read['mode']; 1747 $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp']; 1748 $sensor_data_array['yaw'] = $uuid_bytes_read['yaw']; 1749 $sensor_data_array['pitch'] = $uuid_bytes_read['pitch']; 1750 $sensor_data_array['roll'] = $uuid_bytes_read['roll']; 1751 array_push($atom_structure['sensor_data']['data_type']['accel_data'], $sensor_data_array); 1752 break; 1753 case 2: 1754 $atom_structure['sensor_data']['data_type']['gyro_count']++; 1755 $uuid_bytes_read = unpack('cmode/Jtimestamp/Gyaw/Gpitch/Groll/x*', $sensor_data_content); 1756 $sensor_data_array['mode'] = $uuid_bytes_read['mode']; 1757 $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp']; 1758 $sensor_data_array['yaw'] = $uuid_bytes_read['yaw']; 1759 $sensor_data_array['pitch'] = $uuid_bytes_read['pitch']; 1760 $sensor_data_array['roll'] = $uuid_bytes_read['roll']; 1761 array_push($atom_structure['sensor_data']['data_type']['gyro_data'], $sensor_data_array); 1762 break; 1763 case 3: 1764 $atom_structure['sensor_data']['data_type']['magno_count']++; 1765 $uuid_bytes_read = unpack('cmode/Jtimestamp/Gmagx/Gmagy/Gmagz/x*', $sensor_data_content); 1766 $sensor_data_array['mode'] = $uuid_bytes_read['mode']; 1767 $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp']; 1768 $sensor_data_array['magx'] = $uuid_bytes_read['magx']; 1769 $sensor_data_array['magy'] = $uuid_bytes_read['magy']; 1770 $sensor_data_array['magz'] = $uuid_bytes_read['magz']; 1771 array_push($atom_structure['sensor_data']['data_type']['magno_data'], $sensor_data_array); 1772 break; 1773 case 5: 1774 $atom_structure['sensor_data']['data_type']['gps_count']++; 1775 $uuid_bytes_read = unpack('cmode/Jtimestamp/Glat/Glon/Galt/Gspeed/nbearing/nacc/x*', $sensor_data_content); 1776 $sensor_data_array['mode'] = $uuid_bytes_read['mode']; 1777 $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp']; 1778 $sensor_data_array['lat'] = $uuid_bytes_read['lat']; 1779 $sensor_data_array['lon'] = $uuid_bytes_read['lon']; 1780 $sensor_data_array['alt'] = $uuid_bytes_read['alt']; 1781 $sensor_data_array['speed'] = $uuid_bytes_read['speed']; 1782 $sensor_data_array['bearing'] = $uuid_bytes_read['bearing']; 1783 $sensor_data_array['acc'] = $uuid_bytes_read['acc']; 1784 array_push($atom_structure['sensor_data']['data_type']['gps_data'], $sensor_data_array); 1785 //array_push($debug_structure['debug_items'], $uuid_bytes_read['timestamp']); 1786 break; 1787 case 6: 1788 $atom_structure['sensor_data']['data_type']['rotation_count']++; 1789 $uuid_bytes_read = unpack('cmode/Jtimestamp/Grotx/Groty/Grotz/x*', $sensor_data_content); 1790 $sensor_data_array['mode'] = $uuid_bytes_read['mode']; 1791 $sensor_data_array['timestamp'] = $uuid_bytes_read['timestamp']; 1792 $sensor_data_array['rotx'] = $uuid_bytes_read['rotx']; 1793 $sensor_data_array['roty'] = $uuid_bytes_read['roty']; 1794 $sensor_data_array['rotz'] = $uuid_bytes_read['rotz']; 1795 array_push($atom_structure['sensor_data']['data_type']['rotation_data'], $sensor_data_array); 1796 break; 1797 default: 1798 $atom_structure['sensor_data']['data_type']['unknown_count']++; 1799 break; 1800 } 1801 } 1802 //if (isset($debug_structure['debug_items']) && count($debug_structure['debug_items']) > 0) { 1803 // $atom_structure['sensor_data']['data_type']['debug_list'] = implode(',', $debug_structure['debug_items']); 1804 //} else { 1805 $atom_structure['sensor_data']['data_type']['debug_list'] = 'No debug items in list!'; 1806 //} 1807 break; 1808 1809 default: 1810 $this->warning('Unhandled "uuid" atom identified by "'.$atom_structure['uuid_field_id'].'" at offset '.$atom_structure['offset'].' ('.strlen($atom_data).' bytes)'); 1811 } 1758 1812 break; 1759 1813 … … 1950 2004 // https://www.sno.phy.queensu.ca/~phil/exiftool/TagNames/Kodak.html#frea 1951 2005 if (strlen($atom_data) > 0) { 1952 $info['quicktime']['comments']['picture'][] = array('data'=>$atom_data, 'image_mime'=>'image/jpeg' );2006 $info['quicktime']['comments']['picture'][] = array('data'=>$atom_data, 'image_mime'=>'image/jpeg', 'description'=>'ThumbnailImage'); 1953 2007 } 1954 2008 break; … … 1957 2011 // but the only sample file I've seen has no useful data here 1958 2012 if (strlen($atom_data) > 0) { 1959 $info['quicktime']['comments']['picture'][] = array('data'=>$atom_data, 'image_mime'=>'image/jpeg'); 1960 } 1961 break; 1962 2013 $info['quicktime']['comments']['picture'][] = array('data'=>$atom_data, 'image_mime'=>'image/jpeg', 'description'=>'PreviewImage'); 2014 } 2015 break; 2016 2017 case 'cdsc': // timed metadata reference 2018 // A QuickTime movie can contain none, one, or several timed metadata tracks. Timed metadata tracks can refer to multiple tracks. 2019 // Metadata tracks are linked to the tracks they describe using a track-reference of type 'cdsc'. The metadata track holds the 'cdsc' track reference. 2020 $atom_structure['track_number'] = getid3_lib::BigEndian2Int($atom_data); 2021 break; 1963 2022 1964 2023 default: … … 2000 2059 } 2001 2060 return $atom_structure; 2061 } 2062 if (strlen($subatomdata) < ($subatomsize - 8)) { 2063 // we don't have enough data to decode the subatom. 2064 // this may be because we are refusing to parse large subatoms, or it may be because this atom had its size set too large 2065 // so we passed in the start of a following atom incorrectly? 2066 return $atom_structure; 2002 2067 } 2003 2068 $atom_structure[$subatomcounter++] = $this->QuicktimeParseAtom($subatomname, $subatomsize, $subatomdata, $baseoffset + $subatomoffset, $atomHierarchy, $ParseAllPossibleAtoms); … … 2841 2906 if ($comment_key) { 2842 2907 if ($comment_key == 'picture') { 2843 if (!is_array($data)) { 2844 $image_mime = ''; 2845 if (preg_match('#^\x89\x50\x4E\x47\x0D\x0A\x1A\x0A#', $data)) { 2846 $image_mime = 'image/png'; 2847 } elseif (preg_match('#^\xFF\xD8\xFF#', $data)) { 2848 $image_mime = 'image/jpeg'; 2849 } elseif (preg_match('#^GIF#', $data)) { 2850 $image_mime = 'image/gif'; 2851 } elseif (preg_match('#^BM#', $data)) { 2852 $image_mime = 'image/bmp'; 2853 } 2854 $data = array('data'=>$data, 'image_mime'=>$image_mime); 2855 } 2908 // already copied directly into [comments][picture] elsewhere, do not re-copy here 2909 return true; 2856 2910 } 2857 2911 $gooddata = array($data); … … 2861 2915 } 2862 2916 foreach ($gooddata as $data) { 2863 if ( is_array($data) || (!empty($info['quicktime']['comments'][$comment_key]) && in_array($data, $info['quicktime']['comments'][$comment_key]))) {2917 if (!empty($info['quicktime']['comments'][$comment_key]) && in_array($data, $info['quicktime']['comments'][$comment_key], true)) { 2864 2918 // avoid duplicate copies of identical data 2865 2919 continue; … … 2928 2982 // Pascal strings have 1 unsigned byte at the beginning saying how many chars (1-255) are in the string 2929 2983 return substr($pascalstring, 1); 2984 } 2985 2986 /** 2987 * @param string $pascalstring 2988 * 2989 * @return string 2990 */ 2991 public function MaybePascal2String($pascalstring) { 2992 // Pascal strings have 1 unsigned byte at the beginning saying how many chars (1-255) are in the string 2993 // Check if string actually is in this format or written incorrectly, straight string, or null-terminated string 2994 if (ord(substr($pascalstring, 0, 1)) == (strlen($pascalstring) - 1)) { 2995 return substr($pascalstring, 1); 2996 } elseif (substr($pascalstring, -1, 1) == "\x00") { 2997 // appears to be null-terminated instead of Pascal-style 2998 return substr($pascalstring, 0, -1); 2999 } 3000 return $pascalstring; 2930 3001 } 2931 3002 -
trunk/src/wp-includes/ID3/module.audio-video.riff.php
r47601 r48278 24 24 */ 25 25 26 if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers 27 exit; 28 } 26 29 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.mp3.php', __FILE__, true); 27 30 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ac3.php', __FILE__, true); -
trunk/src/wp-includes/ID3/module.audio.ac3.php
r47601 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_ac3 extends getid3_handler -
trunk/src/wp-includes/ID3/module.audio.dts.php
r47601 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 /** -
trunk/src/wp-includes/ID3/module.audio.flac.php
r46586 r48278 15 15 ///////////////////////////////////////////////////////////////// 16 16 17 17 if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers 18 exit; 19 } 18 20 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.ogg.php', __FILE__, true); 19 21 -
trunk/src/wp-includes/ID3/module.audio.mp3.php
r47602 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 // number of frames to scan to determine if MPEG-audio sequence is valid -
trunk/src/wp-includes/ID3/module.audio.ogg.php
r47601 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 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.audio.flac.php', __FILE__, true); 18 21 -
trunk/src/wp-includes/ID3/module.tag.apetag.php
r46586 r48278 14 14 // /// 15 15 ///////////////////////////////////////////////////////////////// 16 17 if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers 18 exit; 19 } 16 20 17 21 class getid3_apetag extends getid3_handler -
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 -
trunk/src/wp-includes/ID3/module.tag.id3v2.php
r47601 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 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.id3v1.php', __FILE__, true); 18 21 … … 521 524 // note: MusicBrainz Picard incorrectly stores plaintext genres separated by "/" when writing in ID3v2.3 mode, hack-fix here: 522 525 // replace / with NULL, then replace back the two ID3v1 genres that legitimately have "/" as part of the single genre name 523 if (preg_match('#/#', $genrestring)) { 526 if (strpos($genrestring, '/') !== false) { 527 $LegitimateSlashedGenreList = array( // https://github.com/JamesHeinrich/getID3/issues/223 528 'Pop/Funk', // ID3v1 genre #62 - https://en.wikipedia.org/wiki/ID3#standard 529 'Cut-up/DJ', // Discogs - https://www.discogs.com/style/cut-up/dj 530 'RnB/Swing', // Discogs - https://www.discogs.com/style/rnb/swing 531 'Funk / Soul', // Discogs (note spaces) - https://www.discogs.com/genre/funk+%2F+soul 532 ); 524 533 $genrestring = str_replace('/', "\x00", $genrestring); 525 $genrestring = str_replace('Pop'."\x00".'Funk', 'Pop/Funk', $genrestring); 526 $genrestring = str_replace('Rock'."\x00".'Rock', 'Folk/Rock', $genrestring); 534 foreach ($LegitimateSlashedGenreList as $SlashedGenre) { 535 $genrestring = str_ireplace(str_replace('/', "\x00", $SlashedGenre), $SlashedGenre, $genrestring); 536 } 527 537 } 528 538 529 539 // some other taggers separate multiple genres with semicolon, e.g. "Heavy Metal;Thrash Metal;Metal" 530 if ( preg_match('#;#', $genrestring)) {540 if (strpos($genrestring, ';') !== false) { 531 541 $genrestring = str_replace(';', "\x00", $genrestring); 532 542 } -
trunk/src/wp-includes/ID3/module.tag.lyrics3.php
r47601 r48278 15 15 ///////////////////////////////////////////////////////////////// 16 16 17 17 if (!defined('GETID3_INCLUDEPATH')) { // prevent path-exposing attacks that access modules directly on public webservers 18 exit; 19 } 18 20 class getid3_lyrics3 extends getid3_handler 19 21 { … … 108 110 getid3_lib::IncludeDependency(GETID3_INCLUDEPATH.'module.tag.apetag.php', __FILE__, true); 109 111 $getid3_temp = new getID3(); 110 $getid3_temp->openfile($this->getid3->filename );112 $getid3_temp->openfile($this->getid3->filename, $this->getid3->info['filesize'], $this->getid3->fp); 111 113 $getid3_apetag = new getid3_apetag($getid3_temp); 112 114 $getid3_apetag->overrideendoffset = $info['lyrics3']['tag_offset_start'];
Note: See TracChangeset
for help on using the changeset viewer.