Skip to content
This repository was archived by the owner on Dec 2, 2018. It is now read-only.

Commit e2f68b3

Browse files
committed
Only pass on HTTP variables.
1 parent 551a33f commit e2f68b3

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

lib/rack/legacy/cgi.rb

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@ def full_path(path)
4545

4646
# Will run the given path with the given environment
4747
def run(env, *path)
48+
env['DOCUMENT_ROOT'] = public_dir
49+
env['SERVER_SOFTWARE'] = 'Rack Legacy'
4850
status = 200
4951
headers = {}
5052
body = ''
@@ -53,9 +55,10 @@ def run(env, *path)
5355
IO.popen('-', 'r+') do |io|
5456
if io.nil? # Child
5557
$stderr.reopen stderr.path
56-
ENV['DOCUMENT_ROOT'] = public_dir
57-
ENV['SERVER_SOFTWARE'] = 'Rack Legacy'
58-
env.each {|k, v| ENV[k] = v if v.respond_to? :to_str}
58+
env.each do |key, value|
59+
ENV[key] = value if
60+
value.respond_to?(:to_str) && key =~ /^[A-Z_]+$/
61+
end
5962
exec *path
6063
else # Parent
6164
io.write(env['rack.input'].read) if env['rack.input']

0 commit comments

Comments
 (0)