diff options
-rw-r--r-- | app/controllers/application_controller.rb | 2 | ||||
-rw-r--r-- | app/controllers/request_controller.rb | 2 | ||||
-rw-r--r-- | app/models/foi_attachment.rb | 2 | ||||
-rw-r--r-- | app/views/request/_bubble.rhtml | 2 | ||||
-rw-r--r-- | config/boot.rb | 2 | ||||
-rwxr-xr-x | script/handle-mail-replies.rb | 2 | ||||
-rw-r--r-- | spec/integration/errors_spec.rb | 2 |
7 files changed, 7 insertions, 7 deletions
diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index e305e90f4..82884f6c3 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -202,7 +202,7 @@ class ApplicationController < ActionController::Base # return stub path so admin can expire it first_three_digits = info_request.id.to_s()[0..2] path = "views/request/#{first_three_digits}/#{info_request.id}" - foi_cache_path = File.join(File.dirname(__FILE__), '../../cache') + foi_cache_path = File.expand_path(File.join(File.dirname(__FILE__), '../../cache')) return File.join(foi_cache_path, path) end def foi_fragment_cache_exists?(key_path) diff --git a/app/controllers/request_controller.rb b/app/controllers/request_controller.rb index 94fbcde29..4592b5ac2 100644 --- a/app/controllers/request_controller.rb +++ b/app/controllers/request_controller.rb @@ -839,7 +839,7 @@ class RequestController < ApplicationController ) updated = Digest::SHA1.hexdigest(info_request.get_last_event.created_at.to_i.to_s + info_request.updated_at.to_i.to_s) @url_path = "/download/#{updated[0..1]}/#{updated}/#{params[:url_title]}.zip" - file_path = File.join(File.dirname(__FILE__), '../../cache/zips', @url_path) + file_path = File.expand_path(File.join(File.dirname(__FILE__), '../../cache/zips', @url_path)) if !File.exists?(file_path) FileUtils.mkdir_p(File.dirname(file_path)) Zip::ZipFile.open(file_path, Zip::ZipFile::CREATE) { |zipfile| diff --git a/app/models/foi_attachment.rb b/app/models/foi_attachment.rb index f3e3d7e00..9bbf0988f 100644 --- a/app/models/foi_attachment.rb +++ b/app/models/foi_attachment.rb @@ -42,7 +42,7 @@ class FoiAttachment < ActiveRecord::Base if rails_env.nil? || rails_env.empty? raise "$RAILS_ENV is not set" end - base_dir = File.join(File.dirname(__FILE__), "../../cache", "attachments_#{rails_env}") + base_dir = File.expand_path(File.join(File.dirname(__FILE__), "../../cache", "attachments_#{rails_env}")) return File.join(base_dir, self.hexdigest[0..2]) end diff --git a/app/views/request/_bubble.rhtml b/app/views/request/_bubble.rhtml index 87079e9ea..331c2163e 100644 --- a/app/views/request/_bubble.rhtml +++ b/app/views/request/_bubble.rhtml @@ -13,7 +13,7 @@ :file_name => a.display_filename + '.html') %> <% img_filename = "icon_" + a.content_type.sub('/', '_') + "_large.png" - full_filename = File.join(File.dirname(__FILE__), "../../../public/images", img_filename) + full_filename = File.expand_path(File.join(File.dirname(__FILE__), "../../../public/images", img_filename)) if File.exist?(full_filename) %> <a href="<%=attachment_url%>"><img class="attachment_image" alt="Attachment" src="/images/<%=img_filename%>"></a> <% else %> diff --git a/config/boot.rb b/config/boot.rb index 943029408..906a2bace 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -6,7 +6,7 @@ # better. Look for a config/rails_env file, and read stuff from there if # it exists. Put just a line like this in there: # ENV['RAILS_ENV'] = 'production' -rails_env_file = File.join(File.dirname(__FILE__), 'rails_env.rb') +rails_env_file = File.expand_path(File.join(File.dirname(__FILE__), 'rails_env.rb')) if File.exists?(rails_env_file) require rails_env_file end diff --git a/script/handle-mail-replies.rb b/script/handle-mail-replies.rb index 7590f5848..cc15fe35a 100755 --- a/script/handle-mail-replies.rb +++ b/script/handle-mail-replies.rb @@ -12,7 +12,7 @@ # We want to avoid loading rails unless we need it, so we start by just loading the # config file ourselves. -$alaveteli_dir = File.join(File.dirname(__FILE__), '..') +$alaveteli_dir = File.expand_path(File.join(File.dirname(__FILE__), '..')) $:.push(File.join($alaveteli_dir, "commonlib", "rblib")) load "config.rb" MySociety::Config.set_file(File.join($alaveteli_dir, 'config', 'general'), true) diff --git a/spec/integration/errors_spec.rb b/spec/integration/errors_spec.rb index ec2e1c376..4424b58c6 100644 --- a/spec/integration/errors_spec.rb +++ b/spec/integration/errors_spec.rb @@ -33,7 +33,7 @@ describe "When rendering errors" do end it "should render a 403 for attempts at directory listing for attachments" do # make a fake cache - foi_cache_path = File.join(File.dirname(__FILE__), '../../cache') + foi_cache_path = File.expand_path(File.join(File.dirname(__FILE__), '../../cache')) FileUtils.mkdir_p(File.join(foi_cache_path, "views/en/request/101/101/response/1/attach/html/1")) get("/request/101/response/1/attach/html/1/" ) response.code.should == "403" |