Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Sync 2.0 with master #448

Merged
merged 20 commits into from
Jul 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
a300844
Quicktime missing tags on second scan
JamesHeinrich Nov 4, 2023
58b883d
#429 libxml_disable_entity_loader is deprecated
JamesHeinrich Nov 10, 2023
19c9d00
#430 RIFF only return comment string up to first null
JamesHeinrich Dec 30, 2023
2622a43
do not crash on empty seconds in DSS module
jmper Feb 1, 2024
23e4a2c
Merge pull request #434 from jmper/dsstimestamps
JamesHeinrich Feb 1, 2024
448085f
Compatibility fix for PHP 5.3
StudioMaX Feb 1, 2024
86e78ed
Update deprecated actions/checkout; lint against PHP 8.4
StudioMaX Feb 1, 2024
3bcea90
Merge pull request #435 from StudioMaX/php53fix
JamesHeinrich Feb 1, 2024
c9271a6
Merge pull request #436 from StudioMaX/gh-actions
JamesHeinrich Feb 1, 2024
e0e49e2
Upgrade PHPStan to v1.10.57
StudioMaX Feb 2, 2024
fff2dc3
Merge pull request #437 from StudioMaX/update-phpstan
JamesHeinrich Feb 2, 2024
a94fb70
#438 basic GPX format detection
JamesHeinrich Feb 19, 2024
449956e
APE 32-bit PHP warning
JamesHeinrich Mar 23, 2024
143af33
#440 Mpeg duration error due to error in GOP parsing
JamesHeinrich Mar 26, 2024
1192b61
#442 Warning on PrintHexBytes function when $string is not a string
JamesHeinrich Apr 26, 2024
d0e347f
#444 ID3v2 Uninitialized string offset 0
JamesHeinrich May 20, 2024
371330a
add demos
jasonvarga Jun 6, 2024
6415492
Merge pull request #445 from jasonvarga/demos-gitattributes
JamesHeinrich Jun 6, 2024
6e6cd91
Merge branch 'refs/heads/master' into sync-2.0-with-master
StudioMaX Jul 28, 2024
d4b6ef8
Execute tests against PHP 8.4
StudioMaX Jul 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ Doxyfile export-ignore
/phpstan.neon export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/demos export-ignore
22 changes: 16 additions & 6 deletions .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ jobs:
lint:
name: "Lint"
runs-on: "ubuntu-latest"
continue-on-error: ${{ matrix.experimental }}
strategy:
fail-fast: false
matrix:
Expand All @@ -22,26 +23,34 @@ jobs:
- "8.1"
- "8.2"
- "8.3"
experimental:
- false
include:
- php-version: "8.4"
experimental: true
composer-options: "--ignore-platform-reqs"
steps:
- uses: "actions/checkout@v3"
- uses: "actions/checkout@v4"
- uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
ini-values: error_reporting=-1, display_errors=On
coverage: "none"
- uses: "ramsey/composer-install@v2"
with:
composer-options: "${{ matrix.composer-options }}"
- name: "Run the linter"
run: "composer lint -- --colors"

static-analysis:
name: "Static Analysis"
runs-on: "ubuntu-latest"
steps:
- uses: "actions/checkout@v3"
- uses: "actions/checkout@v4"
- uses: "shivammathur/setup-php@v2"
with:
php-version: "7.4"
tools: "phpstan:1.8.11"
php-version: "8.2"
tools: "phpstan:1.10.57"
coverage: "none"
- uses: "ramsey/composer-install@v2"
- name: "Run PHPStan"
Expand All @@ -66,14 +75,15 @@ jobs:
- "8.0"
- "8.1"
- "8.2"
- "8.3"
experimental:
- false
include:
- php-version: "8.3"
- php-version: "8.4"
experimental: true
composer-options: "--ignore-platform-reqs"
steps:
- uses: "actions/checkout@v3"
- uses: "actions/checkout@v4"
- uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/Dbm.php
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ public function analyze($filename, $filesize=null, $original_filename='', $fp=nu
$result = parent::analyze($filename, $filesize, $original_filename, $fp);

// Save result
if (isset($key) && file_exists($filename)) {
if ($key !== null) {
dba_insert($key, serialize($result), $this->dba);
}

Expand Down
15 changes: 12 additions & 3 deletions src/GetID3.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ class GetID3
*/
protected $startup_warning = '';

const VERSION = '2.0.x-202310190849';
const VERSION = '2.0.x-202405201327';
const FREAD_BUFFER_SIZE = 32768;

const ATTACHMENTS_NONE = false;
Expand All @@ -341,10 +341,10 @@ public function __construct() {
$memoryLimit = ini_get('memory_limit');
if (preg_match('#([0-9]+) ?M#i', $memoryLimit, $matches)) {
// could be stored as "16M" rather than 16777216 for example
$memoryLimit = $matches[1] * 1048576;
$memoryLimit = (int) $matches[1] * 1048576;
} elseif (preg_match('#([0-9]+) ?G#i', $memoryLimit, $matches)) { // The 'G' modifier is available since PHP 5.1.0
// could be stored as "2G" rather than 2147483648 for example
$memoryLimit = $matches[1] * 1073741824;
$memoryLimit = (int) $matches[1] * 1073741824;
}
$this->memory_limit = $memoryLimit;

Expand Down Expand Up @@ -1265,6 +1265,15 @@ public function GetFileFormatArray() {

// Misc other formats

// GPX - data - GPS Exchange Format
'gpx' => array (
'pattern' => '^<\\?xml [^>]+>[\s]*<gpx ',
'module' => 'Misc\\Gpx',
'mime_type' => 'application/gpx+xml',
'fail_id3' => 'ERROR',
'fail_ape' => 'ERROR',
),

// PAR2 - data - Parity Volume Set Specification 2.0
'par2' => array (
'pattern' => '^PAR2\\x00PKT',
Expand Down
10 changes: 5 additions & 5 deletions src/Module/Audio/Dss.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@ public function Analyze() {
*/
public function DSSdateStringToUnixDate($datestring) {
$y = (int) substr($datestring, 0, 2);
$m = substr($datestring, 2, 2);
$d = substr($datestring, 4, 2);
$h = substr($datestring, 6, 2);
$i = substr($datestring, 8, 2);
$s = substr($datestring, 10, 2);
$m = (int) substr($datestring, 2, 2);
$d = (int) substr($datestring, 4, 2);
$h = (int) substr($datestring, 6, 2);
$i = (int) substr($datestring, 8, 2);
$s = (int) substr($datestring, 10, 2);
$y += (($y < 95) ? 2000 : 1900);
return mktime($h, $i, $s, $m, $d, $y);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Module/Audio/Midi.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public function Analyze() {
$TicksAtCurrentBPM = 0;
while ($eventsoffset < strlen($trackdata)) {
$eventid = 0;
if (isset($MIDIevents[$tracknumber]) && is_array($MIDIevents[$tracknumber])) {
if (isset($MIDIevents[$tracknumber])) {
$eventid = count($MIDIevents[$tracknumber]);
}
$deltatime = 0;
Expand Down
54 changes: 34 additions & 20 deletions src/Module/AudioVideo/Asf.php
Original file line number Diff line number Diff line change
Expand Up @@ -501,13 +501,17 @@ public function Analyze() {
$offset += 2;
$thisfile_asf_scriptcommandobject['command_types_count'] = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
$offset += 2;
for ($CommandTypesCounter = 0; $CommandTypesCounter < $thisfile_asf_scriptcommandobject['command_types_count']; $CommandTypesCounter++) {
$CommandTypeNameLength = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
$offset += 2;
$thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
$offset += $CommandTypeNameLength;
if ($thisfile_asf_scriptcommandobject['command_types_count'] > 0) {
$thisfile_asf_scriptcommandobject['command_types'] = array();
for ($CommandTypesCounter = 0; $CommandTypesCounter < (int) $thisfile_asf_scriptcommandobject['command_types_count']; $CommandTypesCounter++) {
$CommandTypeNameLength = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 2)) * 2; // 2 bytes per character
$offset += 2;
$thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter] = array();
$thisfile_asf_scriptcommandobject['command_types'][$CommandTypesCounter]['name'] = substr($ASFHeaderData, $offset, $CommandTypeNameLength);
$offset += $CommandTypeNameLength;
}
}
for ($CommandsCounter = 0; $CommandsCounter < $thisfile_asf_scriptcommandobject['commands_count']; $CommandsCounter++) {
for ($CommandsCounter = 0; $CommandsCounter < (int) $thisfile_asf_scriptcommandobject['commands_count']; $CommandsCounter++) {
$thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['presentation_time'] = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
$offset += 4;
$thisfile_asf_scriptcommandobject['commands'][$CommandsCounter]['type_index'] = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
Expand Down Expand Up @@ -556,6 +560,8 @@ public function Analyze() {
break;
}
$thisfile_asf_markerobject['markers_count'] = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 4));
/** @var int|float|false $totalMakersCount */
$totalMakersCount = $thisfile_asf_markerobject['markers_count'];
$offset += 4;
$thisfile_asf_markerobject['reserved_2'] = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
$offset += 2;
Expand All @@ -567,7 +573,8 @@ public function Analyze() {
$offset += 2;
$thisfile_asf_markerobject['name'] = substr($ASFHeaderData, $offset, $thisfile_asf_markerobject['name_length']);
$offset += $thisfile_asf_markerobject['name_length'];
for ($MarkersCounter = 0; $MarkersCounter < $thisfile_asf_markerobject['markers_count']; $MarkersCounter++) {
for ($MarkersCounter = 0; $MarkersCounter < $totalMakersCount; $MarkersCounter++) {
$thisfile_asf_markerobject['markers'][$MarkersCounter] = array();
$thisfile_asf_markerobject['markers'][$MarkersCounter]['offset'] = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
$offset += 8;
$thisfile_asf_markerobject['markers'][$MarkersCounter]['presentation_time'] = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 8));
Expand Down Expand Up @@ -617,7 +624,7 @@ public function Analyze() {
}
$thisfile_asf_bitratemutualexclusionobject['stream_numbers_count'] = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
$offset += 2;
for ($StreamNumberCounter = 0; $StreamNumberCounter < $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count']; $StreamNumberCounter++) {
for ($StreamNumberCounter = 0; $StreamNumberCounter < (int) $thisfile_asf_bitratemutualexclusionobject['stream_numbers_count']; $StreamNumberCounter++) {
$thisfile_asf_bitratemutualexclusionobject['stream_numbers'][$StreamNumberCounter] = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
$offset += 2;
}
Expand Down Expand Up @@ -761,7 +768,7 @@ public function Analyze() {
$thisfile_asf_extendedcontentdescriptionobject['objectsize'] = $NextObjectSize;
$thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count'] = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
$offset += 2;
for ($ExtendedContentDescriptorsCounter = 0; $ExtendedContentDescriptorsCounter < $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count']; $ExtendedContentDescriptorsCounter++) {
for ($ExtendedContentDescriptorsCounter = 0; $ExtendedContentDescriptorsCounter < (int) $thisfile_asf_extendedcontentdescriptionobject['content_descriptors_count']; $ExtendedContentDescriptorsCounter++) {
// shortcut
$thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter] = array();
$thisfile_asf_extendedcontentdescriptionobject_contentdescriptor_current = &$thisfile_asf_extendedcontentdescriptionobject['content_descriptors'][$ExtendedContentDescriptorsCounter];
Expand Down Expand Up @@ -957,7 +964,8 @@ public function Analyze() {
$thisfile_asf_streambitratepropertiesobject['objectsize'] = $NextObjectSize;
$thisfile_asf_streambitratepropertiesobject['bitrate_records_count'] = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
$offset += 2;
for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) {
for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < (int) $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) {
$thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter] = array();
$thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] = Utils::LittleEndian2Int(substr($ASFHeaderData, $offset, 2));
$offset += 2;
$thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags']['stream_number'] = $thisfile_asf_streambitratepropertiesobject['bitrate_records'][$BitrateRecordsCounter]['flags_raw'] & 0x007F;
Expand Down Expand Up @@ -1006,7 +1014,7 @@ public function Analyze() {
if (isset($thisfile_asf_streambitratepropertiesobject['bitrate_records_count'])) {
$ASFbitrateAudio = 0;
$ASFbitrateVideo = 0;
for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) {
for ($BitrateRecordsCounter = 0; $BitrateRecordsCounter < (int) $thisfile_asf_streambitratepropertiesobject['bitrate_records_count']; $BitrateRecordsCounter++) {
if (isset($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter])) {
switch ($thisfile_asf_codeclistobject['codec_entries'][$BitrateRecordsCounter]['type_raw']) {
case 1:
Expand All @@ -1030,7 +1038,7 @@ public function Analyze() {
$thisfile_video['bitrate'] = $ASFbitrateVideo;
}
}
if (isset($thisfile_asf['stream_properties_object']) && is_array($thisfile_asf['stream_properties_object'])) {
if (isset($thisfile_asf['stream_properties_object'])) {

$thisfile_audio['bitrate'] = 0;
$thisfile_video['bitrate'] = 0;
Expand Down Expand Up @@ -1067,7 +1075,7 @@ public function Analyze() {
}

if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { // @phpstan-ignore-line
foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) {
foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { // @phpstan-ignore-line
if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) {
$thisfile_asf_audiomedia_currentstream['bitrate'] = $dataarray['bitrate'];
$thisfile_audio['bitrate'] += $dataarray['bitrate'];
Expand Down Expand Up @@ -1153,7 +1161,7 @@ public function Analyze() {
$thisfile_asf_videomedia_currentstream['format_data']['codec_data'] = substr($streamdata['type_specific_data'], $videomediaoffset);

if (!empty($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'])) { // @phpstan-ignore-line
foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) {
foreach ($thisfile_asf['stream_bitrate_properties_object']['bitrate_records'] as $dummy => $dataarray) { // @phpstan-ignore-line
if (isset($dataarray['flags']['stream_number']) && ($dataarray['flags']['stream_number'] == $streamnumber)) {
$thisfile_asf_videomedia_currentstream['bitrate'] = $dataarray['bitrate'];
$thisfile_video['streams'][$streamnumber]['bitrate'] = $dataarray['bitrate'];
Expand Down Expand Up @@ -1266,10 +1274,13 @@ public function Analyze() {
$thisfile_asf_simpleindexobject['maximum_packet_count'] = Utils::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4));
$offset += 4;
$thisfile_asf_simpleindexobject['index_entries_count'] = Utils::LittleEndian2Int(substr($SimpleIndexObjectData, $offset, 4));
/** @var int|float|false $totalIndexEntriesCount */
$totalIndexEntriesCount = $thisfile_asf_simpleindexobject['index_entries_count'];
$offset += 4;

$IndexEntriesData = $SimpleIndexObjectData.$this->fread(6 * $thisfile_asf_simpleindexobject['index_entries_count']);
for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $thisfile_asf_simpleindexobject['index_entries_count']; $IndexEntriesCounter++) {
$IndexEntriesData = $SimpleIndexObjectData.$this->fread(6 * $totalIndexEntriesCount);
for ($IndexEntriesCounter = 0; $IndexEntriesCounter < $totalIndexEntriesCount; $IndexEntriesCounter++) {
$thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter] = array();
$thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_number'] = Utils::LittleEndian2Int(substr($IndexEntriesData, $offset, 4));
$offset += 4;
$thisfile_asf_simpleindexobject['index_entries'][$IndexEntriesCounter]['packet_count'] = Utils::LittleEndian2Int(substr($IndexEntriesData, $offset, 4));
Expand Down Expand Up @@ -1320,9 +1331,10 @@ public function Analyze() {
$offset += 4;

$ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count']);
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < (int) $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
$IndexSpecifierStreamNumber = Utils::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
$offset += 2;
$thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter] = array();
$thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['stream_number'] = $IndexSpecifierStreamNumber;
$thisfile_asf_asfindexobject['index_specifiers'][$IndexSpecifiersCounter]['index_type'] = Utils::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 2));
$offset += 2;
Expand All @@ -1331,17 +1343,19 @@ public function Analyze() {

$ASFIndexObjectData .= $this->fread(4);
$thisfile_asf_asfindexobject['index_entry_count'] = Utils::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
/** @var int|float|false $totalIndexEntryCount */
$totalIndexEntryCount = $thisfile_asf_asfindexobject['index_entry_count'];
$offset += 4;

$ASFIndexObjectData .= $this->fread(8 * $thisfile_asf_asfindexobject['index_specifiers_count']);
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < (int) $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
$thisfile_asf_asfindexobject['block_positions'][$IndexSpecifiersCounter] = Utils::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 8));
$offset += 8;
}

$ASFIndexObjectData .= $this->fread(4 * $thisfile_asf_asfindexobject['index_specifiers_count'] * $thisfile_asf_asfindexobject['index_entry_count']);
for ($IndexEntryCounter = 0; $IndexEntryCounter < $thisfile_asf_asfindexobject['index_entry_count']; $IndexEntryCounter++) {
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
for ($IndexEntryCounter = 0; $IndexEntryCounter < $totalIndexEntryCount; $IndexEntryCounter++) {
for ($IndexSpecifiersCounter = 0; $IndexSpecifiersCounter < (int) $thisfile_asf_asfindexobject['index_specifiers_count']; $IndexSpecifiersCounter++) {
$thisfile_asf_asfindexobject['offsets'][$IndexSpecifiersCounter][$IndexEntryCounter] = Utils::LittleEndian2Int(substr($ASFIndexObjectData, $offset, 4));
$offset += 4;
}
Expand Down
4 changes: 4 additions & 0 deletions src/Module/AudioVideo/Mpeg.php
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,10 @@ public function Analyze() {
$GOPheader['time_code'] = sprintf('%02d'.$time_code_separator.'%02d'.$time_code_separator.'%02d'.$time_code_separator.'%02d', $GOPheader['time_code_hours'], $GOPheader['time_code_minutes'], $GOPheader['time_code_seconds'], $GOPheader['time_code_pictures']);

$info['mpeg']['group_of_pictures'][] = $GOPheader;
} else {
// https://github.com/JamesHeinrich/getID3/issues/440
$this->warning('group_of_pictures['.$GOPcounter.'] no valid bitratemode');
$info['mpeg']['group_of_pictures'][] = array();
}
break;

Expand Down
Loading
Loading