2016/01/06分のコミットです。
CHANGELOGにのったコミットは以下の通りです。
- Take UTC offset into account when assigning string value to time attribute.
- Add short-hand methods for text and blob types in MySQL.
Take UTC offset into account when assigning string value to time attribute.
activemodel/lib/active_model/type/time.rb
の修正です。
timestamp型のattributeにStringの値を渡した場合に、UTC offsetの値が捨てられてしまうバグがあったのを修正しています。
PRより。
class Schedule # t.time :arrival end Schedule.arrival = '12:00:00+03:00' # before Schedule.arrival #=> 2000-01-01 12:00:00 UTC # after Schedule.arrival #=> 2000-01-01 09:00:00 UTC
Add Html template handler that wraps Raw output in an OutputBuffer
actionview/lib/action_view/template/handlers.rb
、
actionview/lib/action_view/template/handlers/html.rb
の修正です。
template handlerにHTMLを出力する為のhtml
handlerを追加しています。
拡張子が.html
の場合にこのhandlerが使用されます。 escape処理もされないようなので、本当に只のhtmlファイルを出力したいときには便利そう。
Prefer inspect over escaping and sorround by quote marks
actionview/lib/action_view/template/handlers/raw.rb
の修正です。
Template::Handlers::Raw#call
メソッドで、内容出力する際、手でescape処理を行っていたのを、#inspect
メソッドで出力するよう修正しています。
def call(template) - escaped = template.source.gsub(':'.freeze, '\:'.freeze) - - '%q:' + escaped + ':;' + "#{template.source.inspect};" end
Merge pull request #22920 from kamipo/fix_connection_create
Active Recordの修正です。
PostgreSQL adapterのconnection#create
メソッドが、元々はconnection#insert
のaliasだったのが、Modularize postgresql adapter by etehtsea · Pull Request #7447 · rails/railsで変更されてしまっていたので、再度connection#insert
のaliasになるよう修正しています。
Move CHANGELOG entry to Active Record
timestamp型のattributeにStringの値を渡した場合に、UTC offsetの値が捨てられてしまうバグがあったのを修正した対応(Take UTC offset into account when assigning string value to time attribute.)のCHANGELOGをActive ModelからActive Recordに移動しています。
コードの修正自体はActive Modelなのですが、ユーザがこの振る舞いの変更に実際に影響を受けるのはAcitve Recordを使用した場合のみなので、Active RecordのCHANGELOGに移動したようです。
Provide a better error message if a user mistypes the name of script with runner
railties/lib/rails/commands/runner.rb
の修正です。
rails runnerで、SyntaxError
、NameError
になった際にヘルプメッセージを表示するよう修正しています。
# before $ ./bin/rails r "Model.undefined_method" railties-4.2.5/lib/rails/commands/runner.rb:62:in `<top (required)>': uninitialized constant Model (NameError) from railties-4.2.5/lib/rails/commands/runner.rb:62:in `eval' from railties-4.2.5/lib/rails/commands/runner.rb:62:in `<top (required)>' from railties-4.2.5/lib/rails/commands/commands_tasks.rb:123:in `require_command!' from railties-4.2.5/lib/rails/commands/commands_tasks.rb:90:in `runner' from railties-4.2.5/lib/rails/commands/commands_tasks.rb:39:in `run_command!' from railties-4.2.5/lib/rails/commands.rb:17:in `<top (required)>'
# after $ ./bin/rails r "Model.undefined_method" Please specify a valid ruby command or the path of a script to run. Run './bin/rails -h' for help.
Merge pull request #22275 from mastahyeti/per-form-csrf
Action Packの修正です。
form毎に異なるCSRF tokenが生成されるよう対応しています。
http method、action(formのpath)をkeyにCSRF tokenが生成されるようになったので、別のformで生成されたCSRF tokenを使用する、という事は出来なくなっています。
<form method="post" action="/user/change_password"><!-- xss --> <form method="post" action="/innocuous"> <input type="hidden" name="authenticity_token" value="thetoken"> </form>
上記のように、XSSにより予期しないアクションにsubmitをされて値を変更されてしまう、というのを防ぐ為の対策のようです。
詳細については、PR(Per-form CSRF tokens by mastahyeti · Pull Request #22275 · rails/rails)のdescriptionをご参考。 CSPを使用している場合に問題になる可能性があるんですねえ。
Merge pull request #21688 from kamipo/add_text_and_blob_shorthand_methods
activerecord/lib/active_record/connection_adapters/mysql/schema_definitions.rb
の修正です。
MySQLのtext、blob型用のショートハンドメソッドを追加しています。
例。
create_table :foos do |t| t.tinyblob :tiny_blob t.mediumblob :medium_blob t.longblob :long_blob t.tinytext :tiny_text t.mediumtext :medium_text t.longtext :long_text end
MySQL、blob / textでこんなに種類あるんですねえ。
Merge pull request #22921 from prathamesh-sonpatki/fix-add-reference
activerecord/lib/active_record/connection_adapters/abstract_adapter.rb
の修正です。
ReferenceDefinition
のautoloadが不足していたで、追加しています。
make generated controller test work correctly
railties/lib/rails/generators/named_base.rb
、
railties/lib/rails/generators/test_unit/controller/templates/functional_test.rb
の修正です。
namespace付きcontrollerを生成した場合に、デフォルトで生成されたテストファイル が動作しないバグがあったのを修正しています。
テストファイルの中でurl helperを使用しているのですが、そのurl helperを生成する際に、namespaceについての考慮が入っていなかった為、問題になっていました。
remove activemodel dependency on builder
activemodel/activemodel.gemspec
の修正です。
Active Modelのdependencyからbuilder
gemを削除しています。
XML Serialization処理で使用していたようなのですが、XML Serializationは別gemに切り出された(Remove XML Serialization from core by zzak · Pull Request #21161 · rails/rails)為、本体からは不要との事で削除しています。
fix remove_index for postgresql when running legacy migrations
activerecord/lib/active_record/migration/compatibility.rb
の修正です。
legacy migrationsの#remove_index
がPostgreSQLでエラーになっていたのを修正しています。
def remove_index(table_name, options = {}) - index_name = index_name_for_remove(table_name, options) - execute "DROP INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)}" + options = { column: options } unless options.is_a?(Hash) + options[:name] = index_name_for_remove(table_name, options) + super(table_name, options) end
connection adapter毎に異なるSQLを生成する必要があったのに、実装がそうなってなかった(固定のSQLを生成するだけになっていた)のが問題だったようです。