Skip to content

Commit

Permalink
Merge branch '4-0-sec' into 4-0-stable
Browse files Browse the repository at this point in the history
* 4-0-sec:
  bumping version for relesase
  correctly escape backslashes in request path globs
  • Loading branch information
tenderlove committed Nov 17, 2014
2 parents a4c2e70 + ee20103 commit 690bdf9
Show file tree
Hide file tree
Showing 10 changed files with 51 additions and 10 deletions.
2 changes: 1 addition & 1 deletion RAILS_VERSION
@@ -1 +1 @@
4.0.11
4.0.12
2 changes: 1 addition & 1 deletion actionmailer/lib/action_mailer/version.rb
@@ -1,7 +1,7 @@
module ActionMailer
# Returns the version of the currently loaded ActionMailer as a Gem::Version
def self.version
Gem::Version.new "4.0.11"
Gem::Version.new "4.0.12"
end

module VERSION #:nodoc:
Expand Down
4 changes: 2 additions & 2 deletions actionpack/lib/action_dispatch/middleware/static.rb
Expand Up @@ -19,7 +19,7 @@ def match?(path)
paths = "#{full_path}#{ext}"

matches = Dir[paths]
match = matches.detect { |m| File.file?(m) }
match = matches.detect { |m| File.file?(m) && File.readable?(m) }
if match
match.sub!(@compiled_root, '')
::Rack::Utils.escape(match)
Expand All @@ -42,7 +42,7 @@ def unescape_path(path)
end

def escape_glob_chars(path)
path.gsub(/[*?{}\[\]]/, "\\\\\\&")
path.gsub(/[*?{}\[\]\\]/, "\\\\\\&")
end

private
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_pack/version.rb
@@ -1,7 +1,7 @@
module ActionPack
# Returns the version of the currently loaded ActionPack as a Gem::Version
def self.version
Gem::Version.new "4.0.11"
Gem::Version.new "4.0.12"
end

module VERSION #:nodoc:
Expand Down
41 changes: 41 additions & 0 deletions actionpack/test/dispatch/static_test.rb
@@ -1,5 +1,6 @@
# encoding: utf-8
require 'abstract_unit'
require 'fileutils'
require 'rbconfig'

module StaticTests
Expand Down Expand Up @@ -157,6 +158,46 @@ def public_path

include StaticTests

def test_custom_handler_called_when_file_is_not_readable
filename = 'unreadable.html.erb'
target = File.join(@root, filename)
FileUtils.touch target
File.chmod 0200, target
assert File.exist? target
assert !File.readable?(target)
path = "/#{filename}"
env = {
"REQUEST_METHOD"=>"GET",
"REQUEST_PATH"=> path,
"PATH_INFO"=> path,
"REQUEST_URI"=> path,
"HTTP_VERSION"=>"HTTP/1.1",
"SERVER_NAME"=>"localhost",
"SERVER_PORT"=>"8080",
"QUERY_STRING"=>""
}
assert_equal(DummyApp.call(nil), @app.call(env))
ensure
File.unlink target
end

def test_custom_handler_called_when_file_is_outside_root_backslash
filename = 'shared.html.erb'
assert File.exist?(File.join(@root, '..', filename))
path = "/%5C..%2F#{filename}"
env = {
"REQUEST_METHOD"=>"GET",
"REQUEST_PATH"=> path,
"PATH_INFO"=> path,
"REQUEST_URI"=> path,
"HTTP_VERSION"=>"HTTP/1.1",
"SERVER_NAME"=>"localhost",
"SERVER_PORT"=>"8080",
"QUERY_STRING"=>""
}
assert_equal(DummyApp.call(nil), @app.call(env))
end

def test_custom_handler_called_when_file_is_outside_root
filename = 'shared.html.erb'
assert File.exist?(File.join(@root, '..', filename))
Expand Down
2 changes: 1 addition & 1 deletion activemodel/lib/active_model/version.rb
@@ -1,7 +1,7 @@
module ActiveModel
# Returns the version of the currently loaded ActiveModel as a Gem::Version
def self.version
Gem::Version.new "4.0.11"
Gem::Version.new "4.0.12"
end

module VERSION #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/version.rb
@@ -1,7 +1,7 @@
module ActiveRecord
# Returns the version of the currently loaded ActiveRecord as a Gem::Version
def self.version
Gem::Version.new "4.0.11"
Gem::Version.new "4.0.12"
end

module VERSION #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/version.rb
@@ -1,7 +1,7 @@
module ActiveSupport
# Returns the version of the currently loaded ActiveSupport as a Gem::Version
def self.version
Gem::Version.new "4.0.11"
Gem::Version.new "4.0.12"
end

module VERSION #:nodoc:
Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/version.rb
Expand Up @@ -2,7 +2,7 @@ module Rails
module VERSION
MAJOR = 4
MINOR = 0
TINY = 11
TINY = 12
PRE = nil

STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
Expand Down
2 changes: 1 addition & 1 deletion version.rb
Expand Up @@ -2,7 +2,7 @@ module Rails
module VERSION
MAJOR = 4
MINOR = 0
TINY = 11
TINY = 12
PRE = nil

STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
Expand Down

0 comments on commit 690bdf9

Please sign in to comment.