From ba20d8d5af9b132a32e953ad44a210aa52985d93 Mon Sep 17 00:00:00 2001 From: Shish Date: Tue, 27 Aug 2019 00:09:35 +0100 Subject: [PATCH] filter non-ascii domains --- ext/rule34/main.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/ext/rule34/main.php b/ext/rule34/main.php index 3e9c650c..a3330498 100644 --- a/ext/rule34/main.php +++ b/ext/rule34/main.php @@ -68,6 +68,17 @@ class Rule34 extends Extension { } + public function onSourceSet(SourceSetEvent $event) + { + // Maybe check for 404? + if (empty($event->source)) { + return; + } + if (!preg_match("/^(https?:\/\/)?[a-zA-Z0-9\.\-]+(\/.*)?$/", $event->source)) { + throw new SCoreException("Invalid source URL"); + } + } + public function onPageRequest(PageRequestEvent $event) { global $database, $page, $user;