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 })