4285: use regexp to prepent ./ to file path
authorradhika <radhika@curoverse.com>
Mon, 27 Oct 2014 15:28:19 +0000 (11:28 -0400)
committerradhika <radhika@curoverse.com>
Mon, 27 Oct 2014 15:28:19 +0000 (11:28 -0400)
apps/workbench/app/controllers/collections_controller.rb

index b484df36318eb609ef3ba94d84d55eaa29c749e7..e869824be415d57cc0eddc8d1ee15fa50698eb04 100644 (file)
@@ -146,8 +146,7 @@ class CollectionsController < ApplicationController
       coll = Collection.find(params[:uuid])
     end
 
-    file_name = params[:file]
-    file_name = ('./' + file_name) if (file_name and file_name.include?('/'))
+    file_name = params[:file].andand.sub(/^(\.\/|\/|)/, './')
     if usable_token.nil?
       return  # Response already rendered.
     elsif file_name.nil? or not coll.manifest.has_file?(file_name)