File tree Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Expand file tree Collapse file tree 3 files changed +15
-0
lines changed Original file line number Diff line number Diff line change
1
+ * Make ` ActiveSupport::Gzip.compress ` deterministic based on input.
2
+
3
+ ` ActiveSupport::Gzip.compress ` used to include a timestamp in the output,
4
+ causing consecutive calls with the same input data to have different output
5
+ if called during different seconds. It now always sets the timestamp to ` 0 `
6
+ so that the output is identical for any given input.
7
+
8
+ * Rob Brackett*
9
+
1
10
* Given an array of ` Thread::Backtrace::Location ` objects, the new method
2
11
` ActiveSupport::BacktraceCleaner#clean_locations ` returns an array with the
3
12
clean ones:
Original file line number Diff line number Diff line change @@ -32,6 +32,7 @@ def self.decompress(source)
32
32
def self . compress ( source , level = Zlib ::DEFAULT_COMPRESSION , strategy = Zlib ::DEFAULT_STRATEGY )
33
33
output = Stream . new
34
34
gz = Zlib ::GzipWriter . new ( output , level , strategy )
35
+ gz . mtime = 0
35
36
gz . write ( source )
36
37
gz . close
37
38
output . string
Original file line number Diff line number Diff line change @@ -42,4 +42,9 @@ def test_decompress_checks_crc
42
42
ActiveSupport ::Gzip . decompress ( compressed )
43
43
end
44
44
end
45
+
46
+ def test_sets_mtime_to_zero
47
+ compressed = ActiveSupport ::Gzip . compress ( "Hello World" )
48
+ assert_equal Time . at ( 0 ) , Zlib ::GzipReader . new ( StringIO . new ( compressed ) ) . mtime
49
+ end
45
50
end
You can’t perform that action at this time.
0 commit comments