From 28ad3d966062aac975ac5919b609aa3df477467c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Garc=C3=ADa?= Date: Mon, 21 Feb 2022 20:48:19 +0100 Subject: [PATCH 1/2] Fix remote urls pattern --- src/GetID3.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/GetID3.php b/src/GetID3.php index 8318e5e9..d59e6f2c 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://#', $filename)) { + if (preg_match('#^(ht|f)tp(s)://#', $filename)) { throw new Exception('Remote files are not supported - please copy the file locally first'); } From 4784cf481aa8f8f0717de4612d536cc42655f7d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20Garc=C3=ADa?= Date: Mon, 21 Feb 2022 20:48:19 +0100 Subject: [PATCH 2/2] Fix remote urls pattern --- src/GetID3.php | 2 +- tests/UrlsTest.php | 61 ++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 tests/UrlsTest.php 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()); + } + } + +}