admin_data 1.1.1 → 1.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,12 +3,16 @@ module AdminData
3
3
 
4
4
  def serve
5
5
 
6
- # validate filename with a white list
7
- unless self.class.admin_data_assets.include? params[:file]
6
+
7
+ path = File.join(AdminData.public_dir,params[:file])
8
+ expanded_path = File.expand_path(path)
9
+
10
+ # validate that expanded path has admin_data
11
+ unless expanded_path =~ /admin_data/
8
12
  render :nothing => true, :status => 404 and return
9
13
  end
10
14
 
11
- opts = {:text => File.read(File.join(AdminData.public_dir,params[:file])), :cache => true}
15
+ opts = {:text => File.read(path), :cache => true}
12
16
 
13
17
  case params[:file]
14
18
  when /\.css$/i then opts[:content_type] = "text/css"
@@ -21,17 +25,6 @@ module AdminData
21
25
  render opts
22
26
  end
23
27
 
24
- protected
25
-
26
- # Cached list of all assets provided by admin_data
27
- # It is used to ensure security in the serve method
28
- def self.admin_data_assets
29
- @admin_data_assets ||= (
30
- Dir.glob(File.join(AdminData.public_dir, '**', '*')).map do |path|
31
- # we want only relative paths
32
- path.split(AdminData.public_dir, 2).last
33
- end
34
- )
35
- end
28
+
36
29
  end
37
30
  end
@@ -1,3 +1,3 @@
1
1
  module AdminData
2
- VERSION = '1.1.1'
2
+ VERSION = '1.1.2'
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: admin_data
3
3
  version: !ruby/object:Gem::Version
4
- hash: 17
4
+ hash: 23
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 1
9
- - 1
10
- version: 1.1.1
9
+ - 2
10
+ version: 1.1.2
11
11
  platform: ruby
12
12
  authors:
13
13
  - Neeraj Singh