Make WordPress Core


Ignore:
Timestamp:
10/10/2021 01:15:16 AM (5 years ago)
Author:
SergeyBiryukov
Message:

External Libraries: Revert [51900] for now to investigate test failures.

See #54162.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/ID3/getid3.php

    r51900 r51901  
    1717if (!defined('GETID3_INCLUDEPATH')) {
    1818        define('GETID3_INCLUDEPATH', dirname(__FILE__).DIRECTORY_SEPARATOR);
     19}
     20// Workaround Bug #39923 (https://bugs.php.net/bug.php?id=39923)
     21if (!defined('IMG_JPG') && defined('IMAGETYPE_JPEG')) {
     22        define('IMG_JPG', IMAGETYPE_JPEG);
    1923}
    2024if (!defined('ENT_SUBSTITUTE')) { // PHP5.3 adds ENT_IGNORE, PHP5.4 adds ENT_SUBSTITUTE
     
    5458                        $basedir .= DIRECTORY_SEPARATOR;
    5559                }
    56                 if (strpos($temp_dir, $basedir) === 0) {
     60                if (preg_match('#^'.preg_quote($basedir).'#', $temp_dir)) {
    5761                        $found_valid_tempdir = true;
    5862                        break;
     
    211215        public $option_fread_buffer_size = 32768;
    212216
    213 
    214 
    215         // module-specific options
    216 
    217         /** archive.rar
    218          * if true use PHP RarArchive extension, if false (non-extension parsing not yet written in getID3)
    219          *
    220          * @var bool
    221          */
    222         public $options_archive_rar_use_php_rar_extension = true;
    223 
    224         /** archive.gzip
    225          * Optional file list - disable for speed.
    226          * Decode gzipped files, if possible, and parse recursively (.tar.gz for example).
    227          *
    228          * @var bool
    229          */
    230         public $options_archive_gzip_parse_contents = false;
    231 
    232         /** audio.midi
    233          * if false only parse most basic information, much faster for some files but may be inaccurate
    234          *
    235          * @var bool
    236          */
    237         public $options_audio_midi_scanwholefile = true;
    238 
    239         /** audio.mp3
    240          * Forces getID3() to scan the file byte-by-byte and log all the valid audio frame headers - extremely slow,
    241          * unrecommended, but may provide data from otherwise-unusable files.
    242          *
    243          * @var bool
    244          */
    245         public $options_audio_mp3_allow_bruteforce = false;
    246 
    247         /** audio.mp3
    248          * number of frames to scan to determine if MPEG-audio sequence is valid
    249          * Lower this number to 5-20 for faster scanning
    250          * Increase this number to 50+ for most accurate detection of valid VBR/CBR mpeg-audio streams
    251          *
     217        // Public variables
     218
     219        /**
     220         * Filename of file being analysed.
     221         *
     222         * @var string
     223         */
     224        public $filename;
     225
     226        /**
     227         * Filepointer to file being analysed.
     228         *
     229         * @var resource
     230         */
     231        public $fp;
     232
     233        /**
     234         * Result array.
     235         *
     236         * @var array
     237         */
     238        public $info;
     239
     240        /**
     241         * @var string
     242         */
     243        public $tempdir = GETID3_TEMP_DIR;
     244
     245        /**
    252246         * @var int
    253247         */
    254         public $options_audio_mp3_mp3_valid_check_frames = 50;
    255 
    256         /** audio.wavpack
    257          * Avoid scanning all frames (break after finding ID_RIFF_HEADER and ID_CONFIG_BLOCK,
    258          * significantly faster for very large files but other data may be missed
    259          *
    260          * @var bool
    261          */
    262         public $options_audio_wavpack_quick_parsing = false;
    263 
    264         /** audio-video.flv
    265          * Break out of the loop if too many frames have been scanned; only scan this
    266          * many if meta frame does not contain useful duration.
    267          *
    268          * @var int
    269          */
    270         public $options_audiovideo_flv_max_frames = 100000;
    271 
    272         /** audio-video.matroska
    273          * If true, do not return information about CLUSTER chunks, since there's a lot of them
    274          * and they're not usually useful [default: TRUE].
    275          *
    276          * @var bool
    277          */
    278         public $options_audiovideo_matroska_hide_clusters    = true;
    279 
    280         /** audio-video.matroska
    281          * True to parse the whole file, not only header [default: FALSE].
    282          *
    283          * @var bool
    284          */
    285         public $options_audiovideo_matroska_parse_whole_file = false;
    286 
    287         /** audio-video.quicktime
    288          * return all parsed data from all atoms if true, otherwise just returned parsed metadata
    289          *
    290          * @var bool
    291          */
    292         public $options_audiovideo_quicktime_ReturnAtomData  = false;
    293 
    294         /** audio-video.quicktime
    295          * return all parsed data from all atoms if true, otherwise just returned parsed metadata
    296          *
    297          * @var bool
    298          */
    299         public $options_audiovideo_quicktime_ParseAllPossibleAtoms = false;
    300 
    301         /** audio-video.swf
    302          * return all parsed tags if true, otherwise do not return tags not parsed by getID3
    303          *
    304          * @var bool
    305          */
    306         public $options_audiovideo_swf_ReturnAllTagData = false;
    307 
    308         /** graphic.bmp
    309          * return BMP palette
    310          *
    311          * @var bool
    312          */
    313         public $options_graphic_bmp_ExtractPalette = false;
    314 
    315         /** graphic.bmp
    316          * return image data
    317          *
    318          * @var bool
    319          */
    320         public $options_graphic_bmp_ExtractData    = false;
    321 
    322         /** graphic.png
    323          * If data chunk is larger than this do not read it completely (getID3 only needs the first
    324          * few dozen bytes for parsing).
    325          *
    326          * @var int
    327          */
    328         public $options_graphic_png_max_data_bytes = 10000000;
    329 
    330         /** misc.pdf
    331          * return full details of PDF Cross-Reference Table (XREF)
    332          *
    333          * @var bool
    334          */
    335         public $options_misc_pdf_returnXREF = false;
    336 
    337         /** misc.torrent
    338          * Assume all .torrent files are less than 1MB and just read entire thing into memory for easy processing.
    339          * Override this value if you need to process files larger than 1MB
    340          *
    341          * @var int
    342          */
    343         public $options_misc_torrent_max_torrent_filesize = 1048576;
    344 
    345 
    346 
    347         // Public variables
    348 
    349         /**
    350          * Filename of file being analysed.
    351          *
     248        public $memory_limit = 0;
     249
     250        /**
    352251         * @var string
    353252         */
    354         public $filename;
    355 
    356         /**
    357          * Filepointer to file being analysed.
    358          *
    359          * @var resource
    360          */
    361         public $fp;
    362 
    363         /**
    364          * Result array.
    365          *
    366          * @var array
    367          */
    368         public $info;
     253        protected $startup_error   = '';
    369254
    370255        /**
    371256         * @var string
    372257         */
    373         public $tempdir = GETID3_TEMP_DIR;
    374 
    375         /**
    376          * @var int
    377          */
    378         public $memory_limit = 0;
    379 
    380         /**
    381          * @var string
    382          */
    383         protected $startup_error   = '';
    384 
    385         /**
    386          * @var string
    387          */
    388258        protected $startup_warning = '';
    389259
    390         const VERSION           = '1.9.21-202109171300';
     260        const VERSION           = '1.9.20-202006061653';
    391261        const FREAD_BUFFER_SIZE = 32768;
    392262
     
    768638                        }
    769639                        $class = new $class_name($this);
    770 
    771                         // set module-specific options
    772                         foreach (get_object_vars($this) as $getid3_object_vars_key => $getid3_object_vars_value) {
    773                                 if (preg_match('#^options_([^_]+)_([^_]+)_(.+)$#i', $getid3_object_vars_key, $matches)) {
    774                                         list($dummy, $GOVgroup, $GOVmodule, $GOVsetting) = $matches;
    775                                         $GOVgroup = (($GOVgroup == 'audiovideo') ? 'audio-video' : $GOVgroup); // variable names can only contain 0-9a-z_ so standardize here
    776                                         if (($GOVgroup == $determined_format['group']) && ($GOVmodule == $determined_format['module'])) {
    777                                                 $class->$GOVsetting = $getid3_object_vars_value;
    778                                         }
    779                                 }
    780                         }
    781 
    782640                        $class->Analyze();
    783641                        unset($class);
     
    14941352                                                        'module'    => 'msoffice',
    14951353                                                        'mime_type' => 'application/octet-stream',
    1496                                                         'fail_id3'  => 'ERROR',
    1497                                                         'fail_ape'  => 'ERROR',
    1498                                                 ),
    1499 
    1500                                 // TORRENT             - .torrent
    1501                                 'torrent' => array(
    1502                                                         'pattern'   => '^(d8\\:announce|d7\\:comment)',
    1503                                                         'group'     => 'misc',
    1504                                                         'module'    => 'torrent',
    1505                                                         'mime_type' => 'application/x-bittorrent',
    15061354                                                        'fail_id3'  => 'ERROR',
    15071355                                                        'fail_ape'  => 'ERROR',
     
    16421490                                                        $value = trim($value, " \r\n\t"); // do not trim nulls from $value!! Unicode characters will get mangled if trailing nulls are removed!
    16431491                                                }
    1644                                                 if (isset($value) && $value !== "") {
     1492                                                if ($value) {
    16451493                                                        if (!is_numeric($key)) {
    16461494                                                                $this->info['tags'][trim($tag_name)][trim($tag_key)][$key] = $value;
     
    22492097                                        break;
    22502098                        }
    2251                         return 0; // fseek returns 0 on success
    2252                 }
    2253 
    2254                 $pos = $bytes;
    2255                 if ($whence == SEEK_CUR) {
    2256                         $pos = $this->ftell() + $bytes;
    2257                 } elseif ($whence == SEEK_END) {
    2258                         $pos = $this->getid3->info['filesize'] + $bytes;
    2259                 }
    2260                 if (!getid3_lib::intValueSupported($pos)) {
    2261                         throw new getid3_exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10);
    2262                 }
    2263 
    2264                 // https://github.com/JamesHeinrich/getID3/issues/327
    2265                 $result = fseek($this->getid3->fp, $bytes, $whence);
    2266                 if ($result !== 0) { // fseek returns 0 on success
    2267                         throw new getid3_exception('cannot fseek('.$pos.'). resource/stream does not appear to support seeking', 10);
    2268                 }
    2269                 return $result;
     2099                        return 0;
     2100                } else {
     2101                        $pos = $bytes;
     2102                        if ($whence == SEEK_CUR) {
     2103                                $pos = $this->ftell() + $bytes;
     2104                        } elseif ($whence == SEEK_END) {
     2105                                $pos = $this->getid3->info['filesize'] + $bytes;
     2106                        }
     2107                        if (!getid3_lib::intValueSupported($pos)) {
     2108                                throw new getid3_exception('cannot fseek('.$pos.') because beyond PHP filesystem limit', 10);
     2109                        }
     2110                }
     2111                return fseek($this->getid3->fp, $bytes, $whence);
    22702112        }
    22712113
     
    23832225         */
    23842226        public function saveAttachment($name, $offset, $length, $image_mime=null) {
    2385                 $fp_dest = null;
    2386                 $dest = null;
    23872227                try {
    23882228
Note: See TracChangeset for help on using the changeset viewer.