2014/07/03分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
actionpack/test/dispatch/request_test.rb
の修正です。
クラス名にtypoがあったのを修正しています。
Fix SQL injection when querying against ranges and bitstrings
activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
、
activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
の修正です。
SQL injection対策を追加しています(CVE-2014-3482、CVE-2014-3483対応)。
PostgreSQLでbitstring
、range
型を使用している時にquote処理が足りて無かったのを追加しています。
コミットログから抜粋。
case value when Range if /range$/ =~ sql_type - "'#{PostgreSQLColumn.range_to_string(value)}'::#{sql_type}" + escaped = quote_string(PostgreSQLColumn.range_to_string(value)) + "#{escaped}::#{sql_type}" else super end @@ -52,8 +53,8 @@ def quote(value, column = nil) #:nodoc: when 'xml' then "xml '#{quote_string(value)}'" when /^bit/ case value - when /^[01]*$/ then "B'#{value}'" # Bit-string notation - when /^[0-9A-F]*$/i then "X'#{value}'" # Hexadecimal notation + when /\A[01]*\Z/ then "B'#{value}'" # Bit-string notation + when /\A[0-9A-F]*\Z/i then "X'#{value}'" # Hexadecimal notation end
range
の方は、PostgreSQLColumn.range_to_string
メソッドを使用するように修正がされ、bitstring
の方は正規表現に"\A \Z"を使用するよう修正されてます。
各バージョン(3.2.19, 4.0.7 & 4.1.3)用のパッチが当然出ているので、心当たりある方は、対応をば。
Quote range strings when quoting PG ranges
activerecord/lib/active_record/connection_adapters/postgresql/quoting.rb
の修正です。
上のコミットに対して、再度修正が行われています。
- "#{escaped}::#{sql_type}" + "'#{escaped}'::#{sql_type}"
シングルクォートの追加対応が行われています。
Merge pull request #16015 from sgrif/sg-ensure-initialized
activerecord/lib/active_record/attribute_set.rb
、
activerecord/lib/active_record/core.rb
の修正です。
PrimaryKeyの初期化処理をAttributeSet
の中に移動しています。
automatically include ActiveModel::Validations when include ActiveModel::SecurePassword
activemodel/lib/active_model/secure_password.rb
の修正です。
include ActiveModel::Validations
を追加しています。
DateTime#to_f
now preserves fractional seconds.
activesupport/lib/active_support/core_ext/date_time/conversions.rb
の修正です。
DateTime#to_f
メソッドで小数部が必ず0を返していたのを、値を返すよう修正しています。
# before DateTime.civil(1999,12,31,19,0,0.5,Rational(-5,24)).to_f # => 946684800.0 # after DateTime.civil(1999,12,31,19,0,0.5,Rational(-5,24)).to_f # => 946684800.5
Only automatically include validations when enabled
再度activemodel/lib/active_model/secure_password.rb
の修正です。
validationsの設定がされている時のみ、include ActiveModel::Validations
するよう修正しています。
Fix escape_once double-escaping hex-encoded entities
activesupport/lib/active_support/core_ext/string/output_safety.rb
の修正です。
HTML_ESCAPE_ONCE_REGEXP
にパターンを追加しています。
- HTML_ESCAPE_ONCE_REGEXP = /["><']|&(?!([a-zA-Z]+|(#\d+));)/ + HTML_ESCAPE_ONCE_REGEXP = /["><']|&(?!([a-zA-Z]+|(#\d+)|(#[xX][\dA-Fa-f]{1,4}));)/
16進文字のエスケープを追加しています。
assert_equal " ' ' λ λ " ' < > ", html_escape_once(" ' ' λ λ \" ' < > ")
html_escape_once
、使った事無いんですよね。どういうユースケースで使用するんだろう。
The hex escape sequence can be of any length
もう一回activesupport/lib/active_support/core_ext/string/output_safety.rb
の修正です。
- HTML_ESCAPE_ONCE_REGEXP = /["><']|&(?!([a-zA-Z]+|(#\d+)|(#[xX][\dA-Fa-f]{1,4}));)/ + HTML_ESCAPE_ONCE_REGEXP = /["><']|&(?!([a-zA-Z]+|(#\d+)|(#[xX][\dA-Fa-f]+));)/
4文字とは限らないからですね。
上記html_escape_once
の対応について、CHANGELOGに追記しています。
Change the JSON renderer to enforce the 'JS' Content Type
actionpack/lib/action_controller/metal/renderers.rb
の修正です。
JSONPでのrequestの場合、content typeにJSONが設定されていた場合でも、JSを設定するよう修正しています。
if options[:callback].present? - self.content_type ||= Mime::JS + if self.content_type.nil? || self.content_type == Mime::JSON + self.content_type = Mime::JS + end
JSONPの場合、content typeにapplication/javascript
を設定しなくてはならないんですよね。Chromeとかだと、application/json
が設定されてた場合、エラーになります。ついこの間、これでエラーに…。
Fix typo in comment https://github.com/rails/rails/commit/3c917dd1ec84299460657237f2f4771086ba1106
activerecord/lib/active_record/relation/calculations.rb
のdocの修正です。
typoの修正。
Use the type object for type casting HStore columns
activerecord/lib/active_record/connection_adapters/postgresql/cast.rb
、
activerecord/lib/active_record/connection_adapters/postgresql/oid/hstore.rb
の修正です。
HStoreカラムの変換処理をCast
からHStore
クラスに移動しています。