Skip to content

Commit

Permalink
Merge pull request #369 from vgpastor/2.0
Browse files Browse the repository at this point in the history
Fix remote urls pattern
  • Loading branch information
JamesHeinrich authored Oct 27, 2022
2 parents ee238d5 + 4784cf4 commit b19ed0e
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/GetID3.php
Original file line number Diff line number Diff line change
Expand Up @@ -432,7 +432,7 @@ public function openfile($filename, $filesize=null, $fp=null) {
$this->info['php_memory_limit'] = (($this->memory_limit > 0) ? $this->memory_limit : false);

// remote files not supported
if (preg_match('#^(ht|f)tp://#', $filename)) {
if (preg_match('#^(ht|f)tps?://#', $filename)) {
throw new Exception('Remote files are not supported - please copy the file locally first');
}

Expand Down
61 changes: 61 additions & 0 deletions tests/UrlsTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
<?php

namespace JamesHeinrich\GetID3\Tests;

use ExternalUrlTest;
use JamesHeinrich\GetID3\Exception;
use JamesHeinrich\GetID3\GetID3;
use PHPUnit\Framework\TestCase;

class UrlsTest extends TestCase
{

public function testHttps()
{
try{
$getID3 = new GetID3();
$info = $getID3->analyze("https://example.com/test.mp3");
$this->assertArrayHasKey('error', $info);
$this->assertContains('Remote files are not supported - please copy the file locally first', $info['error']);
}catch (Exception $e){
$this->assertFalse(true, "Exception: ".$e->getMessage());
}
}

public function testHttp()
{
try{
$getID3 = new GetID3();
$info = $getID3->analyze("http://example.com/test.mp3");
$this->assertArrayHasKey('error', $info);
$this->assertContains('Remote files are not supported - please copy the file locally first', $info['error']);
}catch (Exception $e){
$this->assertFalse(true, "Exception: ".$e->getMessage());
}
}

public function testFtp()
{
try{
$getID3 = new GetID3();
$info = $getID3->analyze("ftp://example.com/test.mp3");
$this->assertArrayHasKey('error', $info);
$this->assertContains('Remote files are not supported - please copy the file locally first', $info['error']);
}catch (Exception $e){
$this->assertFalse(true, "Exception: ".$e->getMessage());
}
}

public function testFtps()
{
try{
$getID3 = new GetID3();
$info = $getID3->analyze("ftps://example.com/test.mp3");
$this->assertArrayHasKey('error', $info);
$this->assertContains('Remote files are not supported - please copy the file locally first', $info['error']);
}catch (Exception $e){
$this->assertFalse(true, "Exception: ".$e->getMessage());
}
}

}

0 comments on commit b19ed0e

Please sign in to comment.