actionpack-page_caching 1.2.0 → 1.2.1
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.
- checksums.yaml +4 -4
- data/actionpack-page_caching.gemspec +1 -1
- data/lib/action_controller/caching/pages.rb +12 -1
- data/test/caching_test.rb +21 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e05a1101088109a89222cab310b3a204adc41ca807298071947a51e41f6d8094
|
4
|
+
data.tar.gz: d8072a7636a2810fc89b2b2aa3527fdc774b0d6d48a369c2557607c4fa2024f7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 419d93b05fa1dad596777d2b184d372605f37f56c24aa3641802dadf4edf610e9db0d2ac25b6704e4e805d0da02e3f43addd7513e4cb6e254a07b2daad6f9abb
|
7
|
+
data.tar.gz: 1a30d10500acd08de97b3e93a460e281a727acedb19b851a315a9b57b48da3c6ad105e55d4387ef6e42fb2a16fb3aaa0f5b2540df13762e20dbda98ace0ca2b7
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |gem|
|
2
2
|
gem.name = "actionpack-page_caching"
|
3
|
-
gem.version = "1.2.
|
3
|
+
gem.version = "1.2.1"
|
4
4
|
gem.author = "David Heinemeier Hansson"
|
5
5
|
gem.email = "david@loudthinking.com"
|
6
6
|
gem.description = "Static page caching for Action Pack (removed from core in Rails 4.0)"
|
@@ -93,6 +93,10 @@ module ActionController
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
+
def normalized_cache_directory
|
97
|
+
File.expand_path(cache_directory)
|
98
|
+
end
|
99
|
+
|
96
100
|
def handle_proc_cache_directory
|
97
101
|
if @controller
|
98
102
|
@controller.instance_exec(&@cache_directory)
|
@@ -153,15 +157,22 @@ module ActionController
|
|
153
157
|
end
|
154
158
|
|
155
159
|
def cache_path(path, extension = nil)
|
156
|
-
File.join(
|
160
|
+
unnormalized_path = File.join(normalized_cache_directory, cache_file(path, extension))
|
161
|
+
normalized_path = File.expand_path(unnormalized_path)
|
162
|
+
|
163
|
+
relative_path if normalized_path.start_with?(normalized_cache_directory)
|
157
164
|
end
|
158
165
|
|
159
166
|
def delete(path)
|
167
|
+
return unless path
|
168
|
+
|
160
169
|
File.delete(path) if File.exist?(path)
|
161
170
|
File.delete(path + ".gz") if File.exist?(path + ".gz")
|
162
171
|
end
|
163
172
|
|
164
173
|
def write(content, path, gzip)
|
174
|
+
return unless path
|
175
|
+
|
165
176
|
FileUtils.makedirs(File.dirname(path))
|
166
177
|
File.open(path, "wb+") { |f| f.write(content) }
|
167
178
|
|
data/test/caching_test.rb
CHANGED
@@ -1,11 +1,13 @@
|
|
1
1
|
require "abstract_unit"
|
2
2
|
require "mocha/setup"
|
3
|
+
require "find"
|
3
4
|
|
4
5
|
CACHE_DIR = "test_cache"
|
5
6
|
# Don't change "../tmp" cavalierly or you might hose something you don't want hosed
|
6
7
|
TEST_TMP_DIR = File.expand_path("../tmp", __FILE__)
|
7
8
|
FILE_STORE_PATH = File.join(TEST_TMP_DIR, CACHE_DIR)
|
8
9
|
|
10
|
+
|
9
11
|
module PageCachingTestHelpers
|
10
12
|
def setup
|
11
13
|
super
|
@@ -175,6 +177,25 @@ class PageCachingTest < ActionController::TestCase
|
|
175
177
|
include PageCachingTestHelpers
|
176
178
|
tests PageCachingTestController
|
177
179
|
|
180
|
+
def test_cache_does_not_escape
|
181
|
+
draw do
|
182
|
+
get "/page_caching_test/ok/:id", to: "page_caching_test#ok"
|
183
|
+
end
|
184
|
+
|
185
|
+
project_root = File.expand_path("../../", __FILE__)
|
186
|
+
|
187
|
+
|
188
|
+
# Make a path that escapes the cache directory
|
189
|
+
get_to_root = "../../../"
|
190
|
+
|
191
|
+
# Make sure this relative path points at the project root
|
192
|
+
assert_equal project_root, File.expand_path(File.join(FILE_STORE_PATH, get_to_root))
|
193
|
+
|
194
|
+
get :ok, params: { id: "#{get_to_root}../pwnd" }
|
195
|
+
|
196
|
+
assert_predicate Find.find(File.join(project_root, "test")).grep(/pwnd/), :empty?
|
197
|
+
end
|
198
|
+
|
178
199
|
def test_page_caching_resources_saves_to_correct_path_with_extension_even_if_default_route
|
179
200
|
draw do
|
180
201
|
get "posts.:format", to: "posts#index", as: :formatted_posts
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: actionpack-page_caching
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-05-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: actionpack
|
@@ -85,7 +85,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
85
85
|
- !ruby/object:Gem::Version
|
86
86
|
version: '0'
|
87
87
|
requirements: []
|
88
|
-
rubygems_version: 3.0.
|
88
|
+
rubygems_version: 3.2.0.pre1
|
89
89
|
signing_key:
|
90
90
|
specification_version: 4
|
91
91
|
summary: Static page caching for Action Pack (removed from core in Rails 4.0)
|