From 929e066051f00ec40c557c953dc174f052318773 Mon Sep 17 00:00:00 2001 From: Harald Eilertsen Date: Sat, 21 Nov 2015 14:00:53 +0100 Subject: Sanitize filename of pdf file before creating it. --- lib/registration.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/registration.rb b/lib/registration.rb index 16be55a..e38f0fe 100644 --- a/lib/registration.rb +++ b/lib/registration.rb @@ -21,6 +21,10 @@ def generate_pdf_for(band, filename) pdf.render(filename) end +def sanitize(s) + s.gsub(/[ ,.:!^'*\/\\]+/, '-') +end + def create_pdf_file_name(band) - filename = "#{Date.today.iso8601}-#{band.name}-#{band.city}.pdf" + filename = "#{Date.today.iso8601}-#{sanitize(band.name)}-#{sanitize(band.city)}.pdf" end -- cgit v1.2.3