diff --git a/ext/rating/main.php b/ext/rating/main.php index 22b331d8..17fa8b0d 100644 --- a/ext/rating/main.php +++ b/ext/rating/main.php @@ -110,7 +110,10 @@ class Ratings extends Extension { public function onImageInfoSet(ImageInfoSetEvent $event) { if($this->can_rate() && isset($_POST["rating"])) { - send_event(new RatingSetEvent($event->image, $_POST['rating'])); + $rating = $_POST["rating"]; + if (Ratings::rating_is_valid($rating)) { + send_event(new RatingSetEvent($event->image, $rating)); + } } } @@ -211,6 +214,22 @@ class Ratings extends Extension { } } + /** + * @param string $rating + * @return bool + */ + public static function rating_is_valid(/*string*/ $rating) { + switch($rating) { + case "s": + case "q": + case "e": + case "u": + return true; + default: + return false; + } + } + /** * FIXME: this is a bit ugly and guessey, should have proper options *