sbsm 1.5.7 → 1.5.8

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d5121512c837227a27ac5adae0dc1f1264a20829
4
- data.tar.gz: 9088b0ec0826c8013ef29ac9e17befea18de4d4d
3
+ metadata.gz: dba5e15c9cf2727c59c4b7cfe76f50130e3e0ed6
4
+ data.tar.gz: 6e20e7c5cc26fac33046dc1163c6499a095067ee
5
5
  SHA512:
6
- metadata.gz: eda614acaf8ca9a2c2fb2678f613868dd7be9364db124182e6992bfb9d514b51f035eedb832147920d98f203740d7759775486147dd93d7062b1c9471a603b33
7
- data.tar.gz: 492ff66f7b38b7f78eb66328056102706f0094b524724e515b84d6ddafdffa781b64d32e9eadb473eda03a852af055dc4151d78f59151ab95e1d18369627bc06
6
+ metadata.gz: 5ed488a5d66ba9297899f60d6b49f56030c063d72beefa81107e82386c51e82fc535701e1c198a80e35744732704240665813909aa9a0e949fba76d5e141b926
7
+ data.tar.gz: 23e5429ccfc47cd67d052eab84e7d945f3bf3ffe4538bd956445fed7a8db7de7277000d6d9292e120045de1fb236feea9a1f725679c5946488173b0e999d50a9
@@ -1,3 +1,7 @@
1
+ === 1.5.8 / 8.08.2017
2
+
3
+ * Fix recognizing mime type for unusual extensions
4
+
1
5
  === 1.5.7 / 8.08.2017
2
6
 
3
7
  * Return nice 404 error for non existing files
@@ -108,8 +108,8 @@ module SBSM
108
108
  end
109
109
 
110
110
  if File.file?(file_name)
111
- if File.extname(file_name).length > 0
112
- mime_type = MimeMagic.by_extension(File.extname(file_name)).type
111
+ if File.extname(file_name).length > 0 && (mime_info = MimeMagic.by_extension(File.extname(file_name)))
112
+ mime_type = mime_info.type
113
113
  else
114
114
  mime_type = MimeMagic.by_path(file_name)
115
115
  end
@@ -1,3 +1,3 @@
1
1
  module SBSM
2
- VERSION = '1.5.7'
2
+ VERSION = '1.5.8'
3
3
  end
@@ -75,6 +75,48 @@ class AppVariantTest < Minitest::Test
75
75
  assert last_response.headers.keys.index('Content-Type')
76
76
  assert_equal('text/html', last_response.headers['Content-Type'])
77
77
  end
78
+ def test_request_file_with_no_mime_info
79
+ session_id_mock = '1234'
80
+ invalid_path = '/window.js.map.dummy'
81
+ file_name = File.expand_path(File.join('doc', invalid_path))
82
+ FileUtils.makedirs(File.dirname(file_name))
83
+ File.open(file_name, 'w+') {|f| f.puts 'dummy'}
84
+
85
+ @app = flexmock('file_app', @app)
86
+ env = { 'HTTP_COOKIE' => "_session_id=#{session_id_mock}" }
87
+ session_store = SBSM::SessionStore.new(app: @app)
88
+ session_mock= flexmock('session', session_store[session_id_mock.to_s])
89
+ session_mock.should_receive(:get_passthru).and_return([invalid_path])
90
+ @app.should_receive(:session_store).and_return(session_store)
91
+
92
+ result = get invalid_path, {}, env
93
+
94
+ assert_equal(true, last_response.ok?)
95
+ assert last_response.headers.keys.index('Content-Type')
96
+ assert_equal('text/plain', last_response.headers['Content-Type'])
97
+ FileUtils.rm(file_name)
98
+ end
99
+ def test_request_file_with_mime_info
100
+ session_id_mock = '1234'
101
+ invalid_path = '/window.png'
102
+ file_name = File.expand_path(File.join('doc', invalid_path))
103
+ FileUtils.makedirs(File.dirname(file_name))
104
+ File.open(file_name, 'w+') {|f| f.puts 'dummy'}
105
+
106
+ @app = flexmock('file_app', @app)
107
+ env = { 'HTTP_COOKIE' => "_session_id=#{session_id_mock}" }
108
+ session_store = SBSM::SessionStore.new(app: @app)
109
+ session_mock= flexmock('session', session_store[session_id_mock.to_s])
110
+ session_mock.should_receive(:get_passthru).and_return([invalid_path])
111
+ @app.should_receive(:session_store).and_return(session_store)
112
+
113
+ result = get invalid_path, {}, env
114
+
115
+ assert_equal(true, last_response.ok?)
116
+ assert last_response.headers.keys.index('Content-Type')
117
+ assert_equal('image/png', last_response.headers['Content-Type'])
118
+ FileUtils.rm(file_name)
119
+ end
78
120
  end
79
121
 
80
122
  class AppTestSimple < Minitest::Test
@@ -133,6 +175,7 @@ class AppTestSimple < Minitest::Test
133
175
  get '/sbsm.css'
134
176
  assert last_response.ok?
135
177
  assert_match css_content, last_response.body
178
+ FileUtils.rm(css_file)
136
179
  end
137
180
  def test_session_about_then_home
138
181
  skip ('TODO: We should test test_post_feedback')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sbsm
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.7
4
+ version: 1.5.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Masaomi Hatakeyama, Zeno R.R. Davatz