From af1cac6d3fae9a7df251d2d384eb9018b548cc06 Mon Sep 17 00:00:00 2001 From: Lucas Date: Sun, 19 Feb 2023 09:55:28 +0000 Subject: [PATCH] api: use a quoted regex for media_id validation --- lib/PoorBooru/API/V0.pm | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/PoorBooru/API/V0.pm b/lib/PoorBooru/API/V0.pm index 337eeb9..a121a12 100644 --- a/lib/PoorBooru/API/V0.pm +++ b/lib/PoorBooru/API/V0.pm @@ -21,7 +21,8 @@ use constant { ROWS_PER_PAGE => 20, }; -my $TAG_NAME_RE = qr/^[0-9]*[A-Z_a-z][0-9A-Z_a-z]*$/; +my $TAG_NAME_RE = qr/^[0-9]*[A-Z_a-z][0-9A-Z_a-z]*$/; +my $NUMERIC_ID_RE = qr/^[1-9][0-9]*$/; sub mkpager ($) { @@ -87,7 +88,7 @@ get "/tag/:tag_id_or_name" => sub { get "/media" => sub { my $page = query_parameters->get("page") // 1; - send_error("Invalid page number", 400) if $page !~ /^[1-9][0-9]*$/; + send_error("Invalid page number", 400) if $page !~ $NUMERIC_ID_RE; my $paged_media = schema("default")->resultset("Media") ->search({}, { order_by => "upload_date", rows => ROWS_PER_PAGE })