diff --git a/core/database.php b/core/database.php index 1e52c162d..bc4307c87 100644 --- a/core/database.php +++ b/core/database.php @@ -82,7 +82,7 @@ private function get_db(): PDO private function connect_engine(): void { - if (\Safe\preg_match("/^([^:]*)/", $this->dsn, $matches)) { + if (preg_match("/^([^:]*)/", $this->dsn, $matches)) { $db_proto = $matches[1]; } else { throw new ServerError("Can't figure out database engine"); diff --git a/core/dbengine.php b/core/dbengine.php index a635f2255..c17176f3c 100644 --- a/core/dbengine.php +++ b/core/dbengine.php @@ -196,7 +196,7 @@ public function create_table_sql(string $name, string $data): string $extras = ""; foreach (explode(",", $data) as $bit) { $matches = []; - if (\Safe\preg_match("/(UNIQUE)? ?INDEX\s*\((.*)\)/", $bit, $matches)) { + if (preg_match("/(UNIQUE)? ?INDEX\s*\((.*)\)/", $bit, $matches)) { $uni = $matches[1]; $col = $matches[2]; $extras .= "CREATE $uni INDEX {$name}_{$col} ON {$name}({$col});"; diff --git a/core/page.php b/core/page.php index 4635bce2b..792188433 100644 --- a/core/page.php +++ b/core/page.php @@ -767,10 +767,7 @@ public static function is_active(array $pages_matched, ?string $url = null): boo */ $url = $url ?? _get_query(); - $re1 = '.*?'; - $re2 = '((?:[a-z][a-z_]+))'; - - if (\Safe\preg_match_all("/".$re1.$re2."/is", $url, $matches)) { + if (preg_match_all("/.*?((?:[a-z][a-z_]+))/is", $url, $matches) > 0) { $url = $matches[1][0]; } diff --git a/core/polyfills.php b/core/polyfills.php index 9c1c0399e..e21c8b1a1 100644 --- a/core/polyfills.php +++ b/core/polyfills.php @@ -4,8 +4,6 @@ namespace Shimmie2; -use function Safe\preg_match; - /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *\ * Things which should be in the core API * \* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ diff --git a/core/util.php b/core/util.php index 1d2b42aca..d23f5db05 100644 --- a/core/util.php +++ b/core/util.php @@ -386,7 +386,7 @@ function path_to_tags(string $path): array { $matches = []; $tags = []; - if (\Safe\preg_match("/\d+ - (.+)\.([a-zA-Z0-9]+)/", basename($path), $matches)) { + if (preg_match("/\d+ - (.+)\.([a-zA-Z0-9]+)/", basename($path), $matches)) { $tags = explode(" ", $matches[1]); } @@ -812,7 +812,7 @@ function shm_tempnam(string $prefix = ""): string function load_balance_url(string $tmpl, string $hash, int $n = 0): string { $matches = []; - if (\Safe\preg_match("/(.*){(.*)}(.*)/", $tmpl, $matches)) { + if (preg_match("/(.*){(.*)}(.*)/", $tmpl, $matches)) { $pre = $matches[1]; $opts = $matches[2]; $post = $matches[3]; diff --git a/ext/ban_words/main.php b/ext/ban_words/main.php index 7e9a372ff..4aaf5c261 100644 --- a/ext/ban_words/main.php +++ b/ext/ban_words/main.php @@ -87,7 +87,7 @@ private function test_text(string $comment, SCoreException $ex): void foreach ($this->get_words() as $word) { if ($word[0] == '/') { // lines that start with slash are regex - if (\Safe\preg_match($word, $comment) === 1) { + if (\Safe\preg_match($word, $comment)) { throw $ex; } } else { diff --git a/ext/index/events.php b/ext/index/events.php index 8f640fa05..83c8628bb 100644 --- a/ext/index/events.php +++ b/ext/index/events.php @@ -81,7 +81,7 @@ public function matches(string $regex): ?array if (is_null($this->term)) { return null; } - if (\Safe\preg_match($regex, $this->term, $matches) === 1) { + if (\Safe\preg_match($regex, $this->term, $matches)) { return $matches; } return null; diff --git a/ext/link_image/test.php b/ext/link_image/test.php index e31616ab4..fe6b38efd 100644 --- a/ext/link_image/test.php +++ b/ext/link_image/test.php @@ -13,7 +13,7 @@ public function testLinkImage(): void $this->get_page("post/view/$image_id"); $matches = []; - \Safe\preg_match("#value='https?://.*/(post/view/[0-9]+)'#", $this->page_to_text(), $matches); + $this->assertNotFalse(preg_match("#value='https?://.*/(post/view/[0-9]+)'#", $this->page_to_text(), $matches)); $this->assertNotEmpty($matches); $page = $this->get_page($matches[1]); $this->assertEquals("Post $image_id: pie", $page->title); diff --git a/ext/media/main.php b/ext/media/main.php index 604fb2238..7abb362e7 100644 --- a/ext/media/main.php +++ b/ext/media/main.php @@ -860,9 +860,8 @@ public static function video_size(string $filename): array } // error_log("Getting size with `$cmd`"); - $regex_sizes = "/Video: .* ([0-9]{1,4})x([0-9]{1,4})/"; - if (\Safe\preg_match($regex_sizes, $output, $regs)) { - if (\Safe\preg_match("/displaymatrix: rotation of (90|270).00 degrees/", $output)) { + if (preg_match("/Video: .* ([0-9]{1,4})x([0-9]{1,4})/", $output, $regs)) { + if (preg_match("/displaymatrix: rotation of (90|270).00 degrees/", $output)) { $size = [(int)$regs[2], (int)$regs[1]]; } else { $size = [(int)$regs[1], (int)$regs[2]]; diff --git a/ext/ouroboros_api/main.php b/ext/ouroboros_api/main.php index 68346a150..9040481fb 100644 --- a/ext/ouroboros_api/main.php +++ b/ext/ouroboros_api/main.php @@ -244,7 +244,7 @@ public function onPageRequest(PageRequestEvent $event): void { global $page, $user; - if (\Safe\preg_match("%\.(xml|json)$%", implode('/', $event->args), $matches) === 1) { + if (preg_match("%\.(xml|json)$%", implode('/', $event->args), $matches)) { $this->type = $matches[1]; if ($this->type == 'json') { $page->set_mime('application/json; charset=utf-8'); @@ -617,6 +617,6 @@ private function tryAuth(): void */ private function match(PageRequestEvent $event, string $page): bool { - return (\Safe\preg_match("%{$page}\.(xml|json)$%", implode('/', $event->args), $matches) === 1); + return (preg_match("%{$page}\.(xml|json)$%", implode('/', $event->args), $matches) === 1); } } diff --git a/ext/post_tags/main.php b/ext/post_tags/main.php index 67ec884ac..61dfc0ed7 100644 --- a/ext/post_tags/main.php +++ b/ext/post_tags/main.php @@ -80,7 +80,7 @@ public function __construct(string $term) public function matches(string $regex): ?array { $matches = []; - if (\Safe\preg_match($regex, $this->term, $matches) === 1) { + if (\Safe\preg_match($regex, $this->term, $matches)) { return $matches; } return null; @@ -108,7 +108,7 @@ public function __construct(string $term, int $image_id) public function matches(string $regex): ?array { $matches = []; - if (\Safe\preg_match($regex, $this->term, $matches) === 1) { + if (\Safe\preg_match($regex, $this->term, $matches)) { return array_values($matches); } return null;