From 682f450561ff3922d068efc85d09da757a29561c Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Sat, 3 Feb 2024 13:05:50 -0600 Subject: [PATCH] better card decline copy - catch renames with too long filenames/paths --- app/supporter.rb | 2 +- models/site_file.rb | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/app/supporter.rb b/app/supporter.rb index fda5b7f5..aff0cabd 100644 --- a/app/supporter.rb +++ b/app/supporter.rb @@ -55,7 +55,7 @@ post '/supporter/update' do plan: plan_type ) rescue Stripe::CardError => e - flash[:error] = "Error: #{Rack::Utils.escape_html e.message}" + flash[:error] = "Error: #{Rack::Utils.escape_html e.message} This is likely caused by incorrect information, or an issue with your credit card. Please try again, or contact your bank." redirect '/supporter' end diff --git a/models/site_file.rb b/models/site_file.rb index 27ae8b51..35837e4a 100644 --- a/models/site_file.rb +++ b/models/site_file.rb @@ -58,6 +58,14 @@ class SiteFile < Sequel::Model current_path = self.path new_path = site.scrubbed_path new_path + if new_path.length > FILE_PATH_CHARACTER_LIMIT + return false, 'new path too long' + end + + if File.basename(new_path).length > FILE_NAME_CHARACTER_LIMIT + return false, 'new filename too long' + end + if new_path == '' return false, 'cannot rename to empty path' end