diff --git a/contrib/danbooru_api/main.php b/contrib/danbooru_api/main.php index 6ea4ae4d..1f1fc5cb 100644 --- a/contrib/danbooru_api/main.php +++ b/contrib/danbooru_api/main.php @@ -58,7 +58,7 @@ class DanbooruApi implements Extension if($event instanceof SearchTermParseEvent) { $matches = array(); - if(preg_match("/md5:([0-9a-fA-F]*)/i", $event->term, $matches)) + if(preg_match("/^md5:([0-9a-fA-F]*)$/i", $event->term, $matches)) { $hash = strtolower($matches[1]); $event->set_querylet(new Querylet("images.hash = '$hash'")); diff --git a/contrib/numeric_score/main.php b/contrib/numeric_score/main.php index 41892c81..29cc6121 100644 --- a/contrib/numeric_score/main.php +++ b/contrib/numeric_score/main.php @@ -77,7 +77,7 @@ class NumericScore implements Extension { if($event instanceof SearchTermParseEvent) { $matches = array(); - if(preg_match("/score(<|<=|=|>=|>)(\d+)/", $event->term, $matches)) { + if(preg_match("/^score(<|<=|=|>=|>)(\d+)$/", $event->term, $matches)) { $cmp = $matches[1]; $score = $matches[2]; $event->set_querylet(new Querylet("numeric_score $cmp $score")); diff --git a/contrib/rating/main.php b/contrib/rating/main.php index 63e4023f..2f320185 100644 --- a/contrib/rating/main.php +++ b/contrib/rating/main.php @@ -84,7 +84,7 @@ class Ratings implements Extension { $set = join(', ', $arr); $event->add_querylet(new Querylet("rating IN ($set)")); } - if(preg_match("/rating=([sqe]+)/", $event->term, $matches)) { + if(preg_match("/^rating=([sqeu]+)$/", $event->term, $matches)) { $sqes = $matches[1]; $arr = array(); for($i=0; $i|<=|>=|=)(\d+)x(\d+)/", $event->term, $matches)) { + if(preg_match("/^size(<|>|<=|>=|=)(\d+)x(\d+)$/", $event->term, $matches)) { $cmp = $matches[1]; $args = array(int_escape($matches[2]), int_escape($matches[3])); $event->add_querylet(new Querylet("width $cmp ? AND height $cmp ?", $args)); } - else if(preg_match("/ratio(<|>|<=|>=|=)(\d+):(\d+)/", $event->term, $matches)) { + else if(preg_match("/^ratio(<|>|<=|>=|=)(\d+):(\d+)$/", $event->term, $matches)) { $cmp = $matches[1]; $args = array(int_escape($matches[2]), int_escape($matches[3])); $event->add_querylet(new Querylet("width / height $cmp ? / ?", $args)); } - else if(preg_match("/(filesize|id)(<|>|<=|>=|=)(\d+[kmg]?b?)/i", $event->term, $matches)) { + else if(preg_match("/^(filesize|id)(<|>|<=|>=|=)(\d+[kmg]?b?)$/i", $event->term, $matches)) { $col = $matches[1]; $cmp = $matches[2]; $val = parse_shorthand_int($matches[3]); $event->add_querylet(new Querylet("images.$col $cmp ?", array($val))); } - else if(preg_match("/hash=([0-9a-fA-F]*)/i", $event->term, $matches)) { + else if(preg_match("/^hash=([0-9a-fA-F]*)$/i", $event->term, $matches)) { $hash = strtolower($matches[2]); $event->add_querylet(new Querylet("images.hash = '$hash'")); } - else if(preg_match("/(filetype|ext)=([a-zA-Z0-9]*)/i", $event->term, $matches)) { + else if(preg_match("/^(filetype|ext)=([a-zA-Z0-9]*)$/i", $event->term, $matches)) { $ext = strtolower($matches[2]); $event->add_querylet(new Querylet("images.ext = '$ext'")); } - else if(preg_match("/(filename|name)=([a-zA-Z0-9]*)/i", $event->term, $matches)) { + else if(preg_match("/^(filename|name)=([a-zA-Z0-9]*)$/i", $event->term, $matches)) { $filename = strtolower($matches[2]); $event->add_querylet(new Querylet("images.filename LIKE '%$filename%'")); } - else if(preg_match("/posted=(([0-9\*]*)?(-[0-9\*]*)?(-[0-9\*]*)?)/", $event->term, $matches)) { + else if(preg_match("/^posted=(([0-9\*]*)?(-[0-9\*]*)?(-[0-9\*]*)?)$/", $event->term, $matches)) { $val = str_replace("*", "%", $matches[1]); $img_search->append(new Querylet("images.posted LIKE '%$val%'")); } diff --git a/ext/user/main.php b/ext/user/main.php index bfacdb1f..1b953d78 100644 --- a/ext/user/main.php +++ b/ext/user/main.php @@ -166,7 +166,7 @@ class UserPage implements Extension { if($event instanceof SearchTermParseEvent) { $matches = array(); - if(preg_match("/(poster|user)=(.*)/i", $event->term, $matches)) { + if(preg_match("/^(poster|user)=(.*)$/i", $event->term, $matches)) { global $config; global $database; $user = User::by_name($config, $database, $matches[2]); @@ -178,7 +178,7 @@ class UserPage implements Extension { } $event->add_querylet(new Querylet("images.owner_id = $user_id")); } - else if(preg_match("/(poster|user)_id=([0-9]+)/i", $event->term, $matches)) { + else if(preg_match("/^(poster|user)_id=([0-9]+)$/i", $event->term, $matches)) { $user_id = int_escape($matches[2]); $event->add_querylet(new Querylet("images.owner_id = $user_id")); }