From 29aa172391146aec4fc52db9585c3788824697cd Mon Sep 17 00:00:00 2001 From: Lucas Gabriel Vuotto Date: Mon, 28 Apr 2025 21:00:32 +0000 Subject: [PATCH] api/v0: make escaped sequences work for search Reorder the regex chars and remove a needless escape while there. --- lib/Pooru/API/V0/Controller/Tags.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Pooru/API/V0/Controller/Tags.pm b/lib/Pooru/API/V0/Controller/Tags.pm index cb423c4..c3c7b0e 100644 --- a/lib/Pooru/API/V0/Controller/Tags.pm +++ b/lib/Pooru/API/V0/Controller/Tags.pm @@ -81,7 +81,7 @@ sub search ($self) status => 200 ) if $q eq ""; - $q =~ s/[\%_\\]/\\$&/g; + $q =~ s/[%\\_]/\\$&/g; $q .= '%'; my %attrs = ( $search_opts{TagCountView}->%*, @@ -95,7 +95,7 @@ sub search ($self) display => $_->display, count => $_->count, }, $self->schema->resultset("TagCountView") - ->search({name => {-like => $q}}, \%attrs); + ->search({name => \["LIKE ? ESCAPE '\\'", $q]}, \%attrs); return $self->render(json => {tags => [@tags]}); }