sbsm 1.5.6 → 1.5.7
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/History.txt +4 -0
- data/lib/sbsm/app.rb +8 -6
- data/lib/sbsm/version.rb +1 -1
- data/test/test_application.rb +20 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d5121512c837227a27ac5adae0dc1f1264a20829
|
4
|
+
data.tar.gz: 9088b0ec0826c8013ef29ac9e17befea18de4d4d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eda614acaf8ca9a2c2fb2678f613868dd7be9364db124182e6992bfb9d514b51f035eedb832147920d98f203740d7759775486147dd93d7062b1c9471a603b33
|
7
|
+
data.tar.gz: 492ff66f7b38b7f78eb66328056102706f0094b524724e515b84d6ddafdffa781b64d32e9eadb473eda03a852af055dc4151d78f59151ab95e1d18369627bc06
|
data/History.txt
CHANGED
data/lib/sbsm/app.rb
CHANGED
@@ -127,15 +127,17 @@ module SBSM
|
|
127
127
|
res = session.process_rack(rack_request: request)
|
128
128
|
thru = session.get_passthru
|
129
129
|
if thru.size > 0
|
130
|
-
file_name = thru.first.untaint
|
131
|
-
response.set_header('Content-Type', MimeMagic.by_extension(File.extname(file_name)).type)
|
132
|
-
response.headers['Content-Disposition'] = "#{thru.last}; filename=#{File.basename(file_name)}"
|
133
|
-
response.headers['Content-Length'] = File.size(file_name).to_s
|
134
130
|
begin
|
131
|
+
file_name = thru.first.untaint
|
132
|
+
raise Errno::ENOENT unless File.exist?(file_name)
|
133
|
+
response.set_header('Content-Type', MimeMagic.by_extension(File.extname(file_name)).type)
|
134
|
+
response.headers['Content-Disposition'] = "#{thru.last}; filename=#{File.basename(file_name)}"
|
135
|
+
response.headers['Content-Length'] = File.size(file_name).to_s
|
135
136
|
response.write(File.open(file_name, File::RDONLY){|file| file.read})
|
136
137
|
rescue Errno::ENOENT, IOError => err
|
137
|
-
|
138
|
-
|
138
|
+
error_msg = "#{file_name} Not found\n"
|
139
|
+
SBSM.error("#{err.message} #{thru.first} => #{error_msg}")
|
140
|
+
return [404, {'Content-Type' => 'text/html', 'Content-Length' => error_msg.size.to_s}, [error_msg]]
|
139
141
|
end
|
140
142
|
else
|
141
143
|
response.write res unless request.request_method.eql?('HEAD')
|
data/lib/sbsm/version.rb
CHANGED
data/test/test_application.rb
CHANGED
@@ -7,6 +7,7 @@ ENV['RACK_ENV'] = 'test'
|
|
7
7
|
ENV['REQUEST_METHOD'] = 'GET'
|
8
8
|
|
9
9
|
require 'minitest/autorun'
|
10
|
+
require 'flexmock/minitest'
|
10
11
|
require 'rack/test'
|
11
12
|
require 'sbsm/app'
|
12
13
|
require 'sbsm/session'
|
@@ -55,6 +56,25 @@ class AppVariantTest < Minitest::Test
|
|
55
56
|
assert last_response.body.empty?
|
56
57
|
assert last_response.headers.keys.index('Content-Type')
|
57
58
|
end
|
59
|
+
def test_request_file
|
60
|
+
session_id_mock = '1234'
|
61
|
+
invalid_path = '/path/to/non/existing/file'
|
62
|
+
|
63
|
+
@app = flexmock('file_app', @app)
|
64
|
+
env = { 'HTTP_COOKIE' => "_session_id=#{session_id_mock}" }
|
65
|
+
session_store = SBSM::SessionStore.new(app: @app)
|
66
|
+
session_mock= flexmock('session', session_store[session_id_mock.to_s])
|
67
|
+
session_mock.should_receive(:get_passthru).and_return([invalid_path])
|
68
|
+
@app.should_receive(:session_store).and_return(session_store)
|
69
|
+
|
70
|
+
result = get invalid_path, {}, env
|
71
|
+
|
72
|
+
assert_equal(false, last_response.ok?)
|
73
|
+
assert_equal(404, last_response.status)
|
74
|
+
assert (last_response.body.to_s.index(invalid_path))
|
75
|
+
assert last_response.headers.keys.index('Content-Type')
|
76
|
+
assert_equal('text/html', last_response.headers['Content-Type'])
|
77
|
+
end
|
58
78
|
end
|
59
79
|
|
60
80
|
class AppTestSimple < Minitest::Test
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sbsm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Masaomi Hatakeyama, Zeno R.R. Davatz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-08-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|