2009-10-21 07:42:48 +02:00
|
|
|
require 'rake'
|
|
|
|
|
|
|
|
desc "This task will perform necessary upgrades to your Instiki installation"
|
2009-08-27 23:57:37 +02:00
|
|
|
task :upgrade_instiki => :environment do
|
2009-10-21 07:42:48 +02:00
|
|
|
ENV['RAILS_ENV'] ||= 'production'
|
|
|
|
puts "Upgrading Instiki in #{ENV['RAILS_ENV']} environment."
|
|
|
|
|
|
|
|
InstikiUpgrade.migrate_db
|
|
|
|
InstikiUpgrade.move_uploaded_files
|
|
|
|
end
|
|
|
|
|
|
|
|
class InstikiUpgrade
|
2009-08-30 06:31:39 +02:00
|
|
|
|
2009-10-21 07:42:48 +02:00
|
|
|
def self.migrate_db
|
|
|
|
ActiveRecord::Base.establish_connection ENV['RAILS_ENV']
|
|
|
|
Rake::Task["db:migrate"].invoke
|
|
|
|
end
|
|
|
|
|
|
|
|
def self.move_uploaded_files
|
|
|
|
Web.all.each do |web|
|
|
|
|
public_path = Rails.root.join("public", web.address)
|
|
|
|
if public_path.exist?
|
|
|
|
webs_path = Rails.root.join("webs", web.address)
|
|
|
|
if webs_path.exist?
|
|
|
|
puts "Warning! The directory #{webs_path} already exists. Skipping."
|
|
|
|
else
|
|
|
|
public_path.rename(webs_path)
|
|
|
|
puts "Moved #{public_path} to #{webs_path}"
|
|
|
|
end
|
Security: Instiki 0.16.2
On Webs with file uploads enabled, uploaded files were stored
(in version 0.16.1 and earlier) in the public/ directory.
This was a security threat. A miscreant could upload a .html file.
When a user clicked on the link to the file, it was opened (unsanitized)
in the browser.
As of version 0.16.2, uploaded files are stored in the webs/
directory. Now, when the user clicks on the link, the file is sent
with the
Content-Disposition: attachment
header set, which causes the file to be downloaded, rather than opened
in the browser. As always, files downloaded from the internets should be
treated with caution. At least, this way, they are not aoutomatically
opened in the browser.
To move your existing uploaded files to the new location, do a
rake upgrade_instiki
2009-01-26 07:21:30 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2009-10-21 07:42:48 +02:00
|
|
|
|
2011-06-15 07:43:38 +02:00
|
|
|
end
|