Skip to content

Commit b19ed0e

Browse files
Merge pull request #369 from vgpastor/2.0
Fix remote urls pattern
2 parents ee238d5 + 4784cf4 commit b19ed0e

File tree

2 files changed

+62
-1
lines changed

2 files changed

+62
-1
lines changed

src/GetID3.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,7 @@ public function openfile($filename, $filesize=null, $fp=null) {
432432
$this->info['php_memory_limit'] = (($this->memory_limit > 0) ? $this->memory_limit : false);
433433

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

tests/UrlsTest.php

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
namespace JamesHeinrich\GetID3\Tests;
4+
5+
use ExternalUrlTest;
6+
use JamesHeinrich\GetID3\Exception;
7+
use JamesHeinrich\GetID3\GetID3;
8+
use PHPUnit\Framework\TestCase;
9+
10+
class UrlsTest extends TestCase
11+
{
12+
13+
public function testHttps()
14+
{
15+
try{
16+
$getID3 = new GetID3();
17+
$info = $getID3->analyze("https://example.com/test.mp3");
18+
$this->assertArrayHasKey('error', $info);
19+
$this->assertContains('Remote files are not supported - please copy the file locally first', $info['error']);
20+
}catch (Exception $e){
21+
$this->assertFalse(true, "Exception: ".$e->getMessage());
22+
}
23+
}
24+
25+
public function testHttp()
26+
{
27+
try{
28+
$getID3 = new GetID3();
29+
$info = $getID3->analyze("http://example.com/test.mp3");
30+
$this->assertArrayHasKey('error', $info);
31+
$this->assertContains('Remote files are not supported - please copy the file locally first', $info['error']);
32+
}catch (Exception $e){
33+
$this->assertFalse(true, "Exception: ".$e->getMessage());
34+
}
35+
}
36+
37+
public function testFtp()
38+
{
39+
try{
40+
$getID3 = new GetID3();
41+
$info = $getID3->analyze("ftp://example.com/test.mp3");
42+
$this->assertArrayHasKey('error', $info);
43+
$this->assertContains('Remote files are not supported - please copy the file locally first', $info['error']);
44+
}catch (Exception $e){
45+
$this->assertFalse(true, "Exception: ".$e->getMessage());
46+
}
47+
}
48+
49+
public function testFtps()
50+
{
51+
try{
52+
$getID3 = new GetID3();
53+
$info = $getID3->analyze("ftps://example.com/test.mp3");
54+
$this->assertArrayHasKey('error', $info);
55+
$this->assertContains('Remote files are not supported - please copy the file locally first', $info['error']);
56+
}catch (Exception $e){
57+
$this->assertFalse(true, "Exception: ".$e->getMessage());
58+
}
59+
}
60+
61+
}

0 commit comments

Comments
 (0)