なるようになるブログ

読書感想文かrailsについてかrubyについてか

rails commit log流し読み(2016/08/12)

2016/08/12分のコミットです。

CHANGELOGへの追加はありませんでした。


Creating a new Topic class instead of class_eval for the existing one

activerecord/test/cases/validations_test.rbの修正です。

numericality validationのテストで、既存のTopicクラスにattribute、validationを追加していたのを、別に新規でTopicクラスを作成するよう修正しています。

-    Topic.class_eval do
+    klass = Class.new(Topic) do

既存のTopicクラスを拡張すると、他のテストに影響が出てしまう為、との事です。


ensure tag/content_tag escapes " in attribute vals

actionview/lib/action_view/helpers/tag_helper.rbの修正です。

tag / content_tagでhtmlを生成する際に、attribute value内の"(ダブルクォート)をエスケープするよう修正しています。

# before
content_tag(:div, "foo", title: sanitize('" onmouseover="alert(1);//'))
=> "<div title=\"\" onmouseover=\"alert(1);//\">foo</div>"


# after
content_tag(:div, "foo", title: sanitize('" onmouseover="alert(1);//'))
#=> "<div title=\"&quot; onmouseover=&quot;alert(1);//\">foo</div>"

ダブルクォートそのままだとXSSに使われてしまう可能性がある為との事です。CVE-2016-6316。


Fix warning: ambiguous first argument

activerecord/test/cases/scoping/relation_scoping_test.rbの修正です。

merge optionのテストでambiguous first argumentのwarningが出ていたので、()を追加し対応しています。


Integration test to prevent regression for the 5th time

railties/test/json_params_parsing_test.rbの修正です。

parameterのformatがJSONだった場合に、null queryが実行されない事を確認する為のテストを追加しています。

Rails 5系には影響が無い為masterに修正のコミットは無いのですが、4.2系でparameterのnilチェックに誤りがあり、DBへのqueryに"IS NULL"やwhereに空文字を指定していまう事があるバグ(CVE-2016-6317)があり、問題が無い事を確認する為に、テストのみ追加しています。


Merge pull request #26118 from alexcameron89/param-encoding-documentation

actionpack/lib/action_controller/metal/parameter_encoding.rbのdocの修正です。

ActionController::ActionController moduleにdocを追加しています。


Merge pull request #26125 from qinix/fix-doc

rails guideのAction Cable Overviewの修正です。

broadcasting nameに誤りがあったのを修正、及びPassing Parameters to Channelsの項のexampleコードで、使用するメソッドに誤りがあったのを修正していまs.


Ensure values are strings before calling gsub

actionview/lib/action_view/helpers/tag_helper.rbの修正です。

ActionView::Helpers::TagHelper::TagBuilder#tag_optionメソッドでvalueの`"(ダブルクォート)をエスケープする前に、to_sでStringに変換してから処理を行うよう修正しています。valueがSymbolやIntegerだった場合にエラーになってしまう為。