From 16c7c2ffd865233b02d38262dca8b954682e2642 Mon Sep 17 00:00:00 2001 From: Mike Colagrosso Date: Fri, 11 Oct 2024 11:30:52 -0600 Subject: [PATCH] Anchor on beginning or ending in preg_match() --- lib/Ebook.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Ebook.php b/lib/Ebook.php index 3450159b..0fff31b0 100644 --- a/lib/Ebook.php +++ b/lib/Ebook.php @@ -1003,7 +1003,7 @@ class Ebook{ } if(isset($this->KindleCoverUrl)){ - if(!preg_match('|/*_EBOK_portrait.jpg|ius', $this->KindleCoverUrl)){ + if(!preg_match('|/*_EBOK_portrait.jpg$|ius', $this->KindleCoverUrl)){ $error->Add(new Exceptions\InvalidEbookKindleCoverUrlException('Invalid Ebook KindleCoverUrl: ' . $this->KindleCoverUrl)); } @@ -1018,7 +1018,7 @@ class Ebook{ } if(isset($this->EpubUrl)){ - if(!preg_match('|/*.epub|ius', $this->EpubUrl)){ + if(!preg_match('|/*.epub$|ius', $this->EpubUrl)){ $error->Add(new Exceptions\InvalidEbookEpubUrlException('Invalid Ebook EpubUrl: ' . $this->EpubUrl)); } @@ -1033,7 +1033,7 @@ class Ebook{ } if(isset($this->AdvancedEpubUrl)){ - if(!preg_match('|/*_advanced.epub|ius', $this->AdvancedEpubUrl)){ + if(!preg_match('|/*_advanced.epub$|ius', $this->AdvancedEpubUrl)){ $error->Add(new Exceptions\InvalidEbookAdvancedEpubUrlException('Invalid Ebook AdvancedEpubUrl: ' . $this->AdvancedEpubUrl)); } @@ -1049,7 +1049,7 @@ class Ebook{ } if(isset($this->KepubUrl)){ - if(!preg_match('|/*.kepub.epub|ius', $this->KepubUrl)){ + if(!preg_match('|/*.kepub.epub$|ius', $this->KepubUrl)){ $error->Add(new Exceptions\InvalidEbookKepubUrlException('Invalid Ebook KepubUrl: ' . $this->KepubUrl)); } @@ -1064,7 +1064,7 @@ class Ebook{ } if(isset($this->Azw3Url)){ - if(!preg_match('|/*.azw3|ius', $this->Azw3Url)){ + if(!preg_match('|/*.azw3$|ius', $this->Azw3Url)){ $error->Add(new Exceptions\InvalidEbookAzw3UrlException('Invalid Ebook Azw3Url: ' . $this->Azw3Url)); } @@ -1079,7 +1079,7 @@ class Ebook{ } if(isset($this->DistCoverUrl)){ - if(!preg_match('|/*cover.jpg|ius', $this->DistCoverUrl)){ + if(!preg_match('|/*cover.jpg$|ius', $this->DistCoverUrl)){ $error->Add(new Exceptions\InvalidEbookDistCoverUrlException('Invalid Ebook DistCoverUrl: ' . $this->DistCoverUrl)); } @@ -1183,7 +1183,7 @@ class Ebook{ } if(isset($this->GitHubUrl)){ - if(!preg_match('|https://github.com/standardebooks/\w+|ius', $this->GitHubUrl)){ + if(!preg_match('|^https://github.com/standardebooks/\w+|ius', $this->GitHubUrl)){ $error->Add(new Exceptions\InvalidEbookGitHubUrlException('Invalid Ebook GitHubUrl: ' . $this->GitHubUrl)); } @@ -1198,7 +1198,7 @@ class Ebook{ } if(isset($this->WikipediaUrl)){ - if(!preg_match('|https://.*wiki.*|ius', $this->WikipediaUrl)){ + if(!preg_match('|^https://.*wiki.*|ius', $this->WikipediaUrl)){ $error->Add(new Exceptions\InvalidEbookWikipediaUrlException('Invalid Ebook WikipediaUrl: ' . $this->WikipediaUrl)); }