なるようになるブログ

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

rails commit log流し読み(2016/06/28)

2016/06/28分のコミットです。

CHANGELOGにのったコミットは以下の通りです。

actionview/CHANGELOG.md


Add #16917 to 5.0.0 release notes

rails guideのRuby on Rails 5.0 Release Notesの修正です。

ActiveSupport::JSON.decodeメソッドにタイムゾーンの指定のない日時の値を渡した際に、タイムゾーンUTCとして扱われていたのを、Railsアプリに指定したtimezoneの値で扱われるよう修正した、Use correct timezone when parsing date in jsonについてrelease noteにエントリーを追加しています。


Clearify CHANGELOG for #23011 [ci skip]

activesupport/CHANGELOG.mdの修正です。

Use correct timezone when parsing date in jsonの対応についてのエントリーを修正しています。


New syntax for tag helpers i.e. tag.br instead of tag(br) #25195

Action Viewの修正です。

htmlタグを生成する為のメソッドを追加しています。

元々は、tag(タグ名) 又は content_tag(タグ名)でhtmlタグの生成が出来たのですが、新たにtag.タグ名の形でhtmlタグの生成が出来るようになっています。

# before
tag(:br, nil, true)
content_tag(:div, content_tag(:p, "Hello world!"), class: "strong")

# after
tag.br
tag.div tag.p("Hello world!"), class: "strong"

HTML 5規格で指定されているタグは使えるようになっているようです。tag.article data: { user_id: 123 }とかも出来る。


Document simple_format handling of \r

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

simple_formatメソッドのdocに\r\n及び\rも変換される旨説明を追加しています。


We default to using aes-256-cbc as our verification/signing cipher. It can accept key lengths of 128, 192 or 256-bit, whereas currently we were providing twice the acceptable value.

activesupport/lib/active_support/key_generator.rbの修正です。

ActiveSupport::KeyGenerator#generate_keyActiveSupport::CachingKeyGenerator#generate_keyメソッドのデフォルトのkey sizeを64から32に修正しています。

Railsのverification/signingはデフォルトではaes-256-cbcが使われている為、key sizeも本来32であるべきだったのですが、64になってしまっていました。ただ、Ruby 2.3までは要求されるよう大きいkey sizeを指定しても問題無かった(Ruby内部で切り捨てていた)のですが、Ruby 2.4ではkey sizeを厳密に見るようになり、必要なkey sizeより大きい値を指定するとエラーになるようになった為、正しい値を使用するよう修正しています。

参考:openssl: make Cipher#key= and #iv= reject too long values · ruby/ruby@ce63526


Merge pull request #25123 from bf4/remove_problematic_mime_test

actionpack/test/dispatch/request/json_params_parsing_test.rbの修正です。

custome json mime typeを登録するテストで使用するmimeapplication/vnd.api+jsonからapplication/vnd.rails+jsonに修正しています。

本来ここには実際は存在しないmime typeを指定する必要があったのですが、application/vnd.api+jsonJSON APIで使用するmime typeであり、application/vnd.api+jsonをこのテストで使用してしまうと、JSON APIRailsデフォルトで使用する対応の方で問題が起きてしまう為、存在しないmime typeを使用するよう修正したとのことです。


Expand list of void elements to match spec from https://html.spec.whatwg.org/multipage/syntax.html#void-elements

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

void elementsの一覧にareaが漏れていたのを追加しています。


Freeze string for default content for tag_strings, which later goes on to create new content. This should also be inline with content being passed should not be mutable

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

TagBuilder#tag_stringメソッドで使用する空文字列をfreezeするよう修正しています。


Bring Boolean Attributes list for AV Tags helper upto speed with current spec.

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

boolean attributeのリストに過不足があったのを修正しています。


Default to frozen string literals in TagHelper.

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

ファイルの先頭にfrozen-string-literal: trueを追加し、コード内の各箇所で行っていた.freezeを削除しています。