Skip to content

Commit

Permalink
Merge branch '3-0-10' into 3-0-stable
Browse files Browse the repository at this point in the history
* 3-0-10:
  bumping rails to 3.0.10
  properly subsituting bad utf8 characters
  Tags with invalid names should also be stripped in order to prevent XSS attacks.  Thanks Sascha Depold for the report.
  prevent sql injection attacks by escaping quotes in column names
  Properly escape glob characters.
  bumping to 3.0.10.rc1
  more changelog updates
  updating CHANGELOGs
  • Loading branch information
tenderlove committed Aug 16, 2011
2 parents 4c8a211 + 4f15f39 commit 0b37704
Show file tree
Hide file tree
Showing 25 changed files with 106 additions and 18 deletions.
2 changes: 1 addition & 1 deletion RAILS_VERSION
Original file line number Original file line Diff line number Diff line change
@@ -1 +1 @@
3.0.9 3.0.10
6 changes: 5 additions & 1 deletion actionmailer/CHANGELOG
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,8 @@
*Rails 3.0.8 (unreleased)* *Rails 3.0.10 (unreleased)*

*Rails 3.0.9 (June 16, 2011)*

*Rails 3.0.8 (June 7, 2011)*


* Mail dependency increased to 2.2.19 * Mail dependency increased to 2.2.19


Expand Down
2 changes: 1 addition & 1 deletion actionmailer/lib/action_mailer/version.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ActionMailer
module VERSION #:nodoc: module VERSION #:nodoc:
MAJOR = 3 MAJOR = 3
MINOR = 0 MINOR = 0
TINY = 9 TINY = 10
PRE = nil PRE = nil


STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
Expand Down
10 changes: 9 additions & 1 deletion actionpack/CHANGELOG
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
* Fixes an issue where cache sweepers with only after filters would have no * Fixes an issue where cache sweepers with only after filters would have no
controller object, it would raise undefined method controller_name for nil [jeroenj] controller object, it would raise undefined method controller_name for nil [jeroenj]


*Rails 3.0.9 (unreleased)* * Ensure status codes are logged when exceptions are raised.

* Subclasses of OutputBuffer are respected.

* Fixed ActionView::FormOptionsHelper#select with :multiple => false

* Avoid extra call to Cache#read in case of a fragment cache hit

*Rails 3.0.9 (June 16, 2011)*


* json_escape will now return a SafeBuffer string if it receives SafeBuffer string [tenderlove] * json_escape will now return a SafeBuffer string if it receives SafeBuffer string [tenderlove]


Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ def parse(parent, line, pos, content, strict=true)
end end


closing = ( scanner.scan(/\//) ? :close : nil ) closing = ( scanner.scan(/\//) ? :close : nil )
return Text.new(parent, line, pos, content) unless name = scanner.scan(/[\w:-]+/) return Text.new(parent, line, pos, content) unless name = scanner.scan(/[^\s!>\/]+/)
name.downcase! name.downcase!


unless closing unless closing
Expand Down
2 changes: 1 addition & 1 deletion actionpack/lib/action_pack/version.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ActionPack
module VERSION #:nodoc: module VERSION #:nodoc:
MAJOR = 3 MAJOR = 3
MINOR = 0 MINOR = 0
TINY = 9 TINY = 10
PRE = nil PRE = nil


STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
Expand Down
6 changes: 5 additions & 1 deletion actionpack/lib/action_view/template/resolver.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ def build_path(name, prefix, partial, details)
end end


def query(path, exts, formats) def query(path, exts, formats)
query = File.join(@path, path) query = escape_entry File.join(@path, path)


exts.each do |ext| exts.each do |ext|
query << '{' << ext.map {|e| e && ".#{e}" }.join(',') << ',}' query << '{' << ext.map {|e| e && ".#{e}" }.join(',') << ',}'
Expand All @@ -88,6 +88,10 @@ def query(path, exts, formats)
templates templates
end end


def escape_entry(entry)
entry.gsub(/(\*|\[|\]|\{|\}|\?)/, "\\\\\\1")
end

# Extract handler and formats from path. If a format cannot be a found neither # Extract handler and formats from path. If a format cannot be a found neither
# from the path, or the handler, we should return the array of formats given # from the path, or the handler, we should return the array of formats given
# to the resolver. # to the resolver.
Expand Down
14 changes: 14 additions & 0 deletions actionpack/test/controller/render_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -396,6 +396,14 @@ def render_with_explicit_template
render :template => "test/hello_world" render :template => "test/hello_world"
end end


def render_with_explicit_unescaped_template
render :template => "test/h*llo_world"
end

def render_with_explicit_escaped_template
render :template => "test/hello_w*rld"
end

def render_with_explicit_string_template def render_with_explicit_string_template
render "test/hello_world" render "test/hello_world"
end end
Expand Down Expand Up @@ -1057,6 +1065,12 @@ def test_render_with_explicit_template
assert_response :success assert_response :success
end end


def test_render_with_explicit_unescaped_template
assert_raise(ActionView::MissingTemplate) { get :render_with_explicit_unescaped_template }
get :render_with_explicit_escaped_template
assert_equal "Hello w*rld!", @response.body
end

def test_render_with_explicit_string_template def test_render_with_explicit_string_template
get :render_with_explicit_string_template get :render_with_explicit_string_template
assert_equal "<html>Hello world!</html>", @response.body assert_equal "<html>Hello world!</html>", @response.body
Expand Down
1 change: 1 addition & 0 deletions actionpack/test/fixtures/test/hello_w*rld.erb
Original file line number Original file line Diff line number Diff line change
@@ -0,0 +1 @@
Hello w*rld!
7 changes: 7 additions & 0 deletions actionpack/test/template/html-scanner/sanitizer_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -5,6 +5,13 @@ def setup
@sanitizer = nil # used by assert_sanitizer @sanitizer = nil # used by assert_sanitizer
end end


def test_strip_tags_with_quote
sanitizer = HTML::FullSanitizer.new
string = '<" <img src="trollface.gif" onload="alert(1)"> hi'

assert_equal ' hi', sanitizer.sanitize(string)
end

def test_strip_tags def test_strip_tags
sanitizer = HTML::FullSanitizer.new sanitizer = HTML::FullSanitizer.new
assert_equal("<<<bad html", sanitizer.sanitize("<<<bad html")) assert_equal("<<<bad html", sanitizer.sanitize("<<<bad html"))
Expand Down
6 changes: 6 additions & 0 deletions activemodel/CHANGELOG
Original file line number Original file line Diff line number Diff line change
@@ -1,3 +1,9 @@
*Rails 3.0.10 (unreleased)*

*Rails 3.0.9 (June 16, 2011)*

*Rails 3.0.8 (June 7, 2011)*

*Rails 3.0.7 (April 18, 2011)* *Rails 3.0.7 (April 18, 2011)*


*No changes. *No changes.
Expand Down
2 changes: 1 addition & 1 deletion activemodel/lib/active_model/version.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ActiveModel
module VERSION #:nodoc: module VERSION #:nodoc:
MAJOR = 3 MAJOR = 3
MINOR = 0 MINOR = 0
TINY = 9 TINY = 10
PRE = nil PRE = nil


STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
Expand Down
12 changes: 12 additions & 0 deletions activerecord/CHANGELOG
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -4,6 +4,18 @@


* schema.rb is written as UTF-8 by default. * schema.rb is written as UTF-8 by default.


* Ensuring an established connection when running `rake db:schema:dump`

* Association conditions will not clobber join conditions.

* Destroying a record will destroy the HABTM record before destroying itself.
GH #402.

* Make `ActiveRecord::Batches#find_each` to not return `self`.

* Update `table_exists?` in PG to to always use current search_path or schema
if explictly set.

*Rails 3.0.9 (June 16, 2011)* *Rails 3.0.9 (June 16, 2011)*


*Rails 3.0.8 (June 7, 2011)* *Rails 3.0.8 (June 7, 2011)*
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def quote(value, column = nil)
end end


def quote_column_name(name) #:nodoc: def quote_column_name(name) #:nodoc:
@quoted_column_names[name] ||= "`#{name}`" @quoted_column_names[name] ||= "`#{name.to_s.gsub('`', '``')}`"
end end


def quote_table_name(name) #:nodoc: def quote_table_name(name) #:nodoc:
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ def quote_string(s) #:nodoc:
end end


def quote_column_name(name) #:nodoc: def quote_column_name(name) #:nodoc:
%Q("#{name}") %Q("#{name.to_s.gsub('"', '""')}")
end end


# Quote date/time values for use in SQL input. Includes microseconds # Quote date/time values for use in SQL input. Includes microseconds
Expand Down
2 changes: 1 addition & 1 deletion activerecord/lib/active_record/version.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ActiveRecord
module VERSION #:nodoc: module VERSION #:nodoc:
MAJOR = 3 MAJOR = 3
MINOR = 0 MINOR = 0
TINY = 9 TINY = 10
PRE = nil PRE = nil


STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
Expand Down
17 changes: 17 additions & 0 deletions activerecord/test/cases/base_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -50,6 +50,23 @@ class Boolean < ActiveRecord::Base; end
class BasicsTest < ActiveRecord::TestCase class BasicsTest < ActiveRecord::TestCase
fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse-things', :authors, :categorizations, :categories, :posts fixtures :topics, :companies, :developers, :projects, :computers, :accounts, :minimalistics, 'warehouse-things', :authors, :categorizations, :categories, :posts


def test_column_names_are_escaped
conn = ActiveRecord::Base.connection
classname = conn.class.name[/[^:]*$/]
badchar = {
'SQLite3Adapter' => '"',
'MysqlAdapter' => '`',
'Mysql2Adapter' => '`',
'PostgreSQLAdapter' => '"',
'OracleAdapter' => '"',
}.fetch(classname) {
raise "need a bad char for #{classname}"
}

quoted = conn.quote_column_name "foo#{badchar}bar"
assert_equal("#{badchar}foo#{badchar * 2}bar#{badchar}", quoted)
end

unless current_adapter?(:PostgreSQLAdapter,:OracleAdapter,:SQLServerAdapter) unless current_adapter?(:PostgreSQLAdapter,:OracleAdapter,:SQLServerAdapter)
def test_limit_with_comma def test_limit_with_comma
assert_nothing_raised do assert_nothing_raised do
Expand Down
6 changes: 5 additions & 1 deletion activeresource/CHANGELOG
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,8 @@
*Rails 3.0.8 (unreleased)* *Rails 3.0.10 (unreleased)*

*Rails 3.0.9 (June 16, 2011)*

*Rails 3.0.8 (June 7, 2011)*


*No changes. *No changes.


Expand Down
2 changes: 1 addition & 1 deletion activeresource/lib/active_resource/version.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ActiveResource
module VERSION #:nodoc: module VERSION #:nodoc:
MAJOR = 3 MAJOR = 3
MINOR = 0 MINOR = 0
TINY = 9 TINY = 10
PRE = nil PRE = nil


STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
Expand Down
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def html_escape(s)
if s.html_safe? if s.html_safe?
s s
else else
s.gsub(/[&"><]/) { |special| HTML_ESCAPE[special] }.html_safe s.to_s.gsub(/&/, "&amp;").gsub(/\"/, "&quot;").gsub(/>/, "&gt;").gsub(/</, "&lt;").html_safe
end end
end end


Expand Down
2 changes: 1 addition & 1 deletion activesupport/lib/active_support/version.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module ActiveSupport
module VERSION #:nodoc: module VERSION #:nodoc:
MAJOR = 3 MAJOR = 3
MINOR = 0 MINOR = 0
TINY = 9 TINY = 10
PRE = nil PRE = nil


STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
Expand Down
7 changes: 7 additions & 0 deletions activesupport/test/core_ext/string_ext_test.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -7,10 +7,17 @@
require 'active_support/time' require 'active_support/time'
require 'active_support/core_ext/kernel/reporting' require 'active_support/core_ext/kernel/reporting'
require 'active_support/core_ext/string/strip' require 'active_support/core_ext/string/strip'
require 'active_support/core_ext/string/output_safety'


class StringInflectionsTest < Test::Unit::TestCase class StringInflectionsTest < Test::Unit::TestCase
include InflectorTestCases include InflectorTestCases


def test_erb_escape
string = [192, 60].pack('CC')
expected = 192.chr + "&lt;"
assert_equal expected, ERB::Util.html_escape(string)
end

def test_strip_heredoc_on_an_empty_string def test_strip_heredoc_on_an_empty_string
assert_equal '', ''.strip_heredoc assert_equal '', ''.strip_heredoc
end end
Expand Down
6 changes: 5 additions & 1 deletion railties/CHANGELOG
Original file line number Original file line Diff line number Diff line change
@@ -1,4 +1,8 @@
*Rails 3.0.8 (unreleased)* *Rails 3.0.10 (unreleased)*

*Rails 3.0.9 (June 16, 2011)*

*Rails 3.0.8 (June 7, 2011)*


* Fix Rake 0.9.0 support. * Fix Rake 0.9.0 support.


Expand Down
2 changes: 1 addition & 1 deletion railties/lib/rails/version.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Rails
module VERSION #:nodoc: module VERSION #:nodoc:
MAJOR = 3 MAJOR = 3
MINOR = 0 MINOR = 0
TINY = 9 TINY = 10
PRE = nil PRE = nil


STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.') STRING = [MAJOR, MINOR, TINY, PRE].compact.join('.')
Expand Down
2 changes: 1 addition & 1 deletion version.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ module Rails
module VERSION #:nodoc: module VERSION #:nodoc:
MAJOR = 3 MAJOR = 3
MINOR = 0 MINOR = 0
TINY = 9 TINY = 10
PRE = nil PRE = nil


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

0 comments on commit 0b37704

Please sign in to comment.