summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorHarald Eilertsen <haraldei@anduin.net>2015-11-21 14:00:53 +0100
committerHarald Eilertsen <haraldei@anduin.net>2015-11-21 14:00:53 +0100
commit929e066051f00ec40c557c953dc174f052318773 (patch)
treee2f6346ce72ce3a6e99d7ac46c7349ed2974317f /lib
parente02db5a74637c2c5b6f837011f1b1a103ed0d10e (diff)
downloadnorsk-urskog-registrations-929e066051f00ec40c557c953dc174f052318773.tar.gz
norsk-urskog-registrations-929e066051f00ec40c557c953dc174f052318773.tar.bz2
norsk-urskog-registrations-929e066051f00ec40c557c953dc174f052318773.zip
Sanitize filename of pdf file before creating it.
Diffstat (limited to 'lib')
-rw-r--r--lib/registration.rb6
1 files changed, 5 insertions, 1 deletions
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