diff --git a/src/GetID3.php b/src/GetID3.php index d59e6f2c..b747e7af 100644 --- a/src/GetID3.php +++ b/src/GetID3.php @@ -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(s)://#', $filename)) { + if (preg_match('#^(ht|f)tps?://#', $filename)) { throw new Exception('Remote files are not supported - please copy the file locally first'); } diff --git a/tests/UrlsTest.php b/tests/UrlsTest.php new file mode 100644 index 00000000..195a28aa --- /dev/null +++ b/tests/UrlsTest.php @@ -0,0 +1,61 @@ +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()); + } + } + +}