summaryrefslogtreecommitdiffstats
path: root/db/migrate
diff options
context:
space:
mode:
authorJean-Philippe Lang <jp_lang@yahoo.fr>2013-09-11 21:31:59 +0000
committerJean-Philippe Lang <jp_lang@yahoo.fr>2013-09-11 21:31:59 +0000
commit9149425750372103dc9399cf1d8436979402c865 (patch)
treed6b8c22712ada3f54bb5abb5d8764d4bda61a494 /db/migrate
parent02fca76c13cde18859eaf6dde2381328feaacb39 (diff)
downloadredmine-9149425750372103dc9399cf1d8436979402c865.tar.gz
redmine-9149425750372103dc9399cf1d8436979402c865.zip
Remove EOLs from attachments filename (#14819).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@12129 e93f8b46-1217-0410-a6f0-8f06a7374b81
Diffstat (limited to 'db/migrate')
-rw-r--r--db/migrate/20130911193200_remove_eols_from_attachments_filename.rb12
1 files changed, 12 insertions, 0 deletions
diff --git a/db/migrate/20130911193200_remove_eols_from_attachments_filename.rb b/db/migrate/20130911193200_remove_eols_from_attachments_filename.rb
new file mode 100644
index 000000000..3708031e0
--- /dev/null
+++ b/db/migrate/20130911193200_remove_eols_from_attachments_filename.rb
@@ -0,0 +1,12 @@
+class RemoveEolsFromAttachmentsFilename < ActiveRecord::Migration
+ def up
+ Attachment.where("filename like ? or filename like ?", "%\r%", "%\n%").each do |attachment|
+ filename = attachment.filename.to_s.tr("\r\n", "_")
+ Attachment.where(:id => attachement.id).update_all(:filename => filename)
+ end
+ end
+
+ def down
+ # nop
+ end
+end