From f31878bc2c68f14689690383d38fbebd9db1ea0c Mon Sep 17 00:00:00 2001 From: evazion Date: Wed, 30 Mar 2022 22:45:44 -0500 Subject: [PATCH] Fix blank error page when performing search with invalid regex. Fix searches like this: https://danbooru.donmai.us/artist_urls?search[url_not_regex]=https://www/.artstation/.com/[a-zA-Z0-9-.] returning a HTTP 500 error with a blank page. Here the problem is that Postgres raises an error because `[a-zA-Z0-9-.]` is an invalid character class (it should be `[a-ZA-Z0-9.-]`). This error happens on the error page itself, when rendering the / links in the , so it causes the error page to fail. --- app/helpers/components_helper.rb | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/helpers/components_helper.rb b/app/helpers/components_helper.rb index 18d7ca1a8..fdb4843c6 100644 --- a/app/helpers/components_helper.rb +++ b/app/helpers/components_helper.rb @@ -86,6 +86,8 @@ module ComponentsHelper # The / links in the element of the . def render_meta_links(records) render PaginatorComponent.new(records: records, params: params).with_variant(:meta_links) + rescue ActiveRecord::StatementInvalid + # Swallow any exceptions when loading records so that the page load doesn't fail. end def numbered_paginator(records)