rc1以後の更新はありません。
🔗 Action Pack CHANGELOG(v7.1.0.rc1)
🔗 Support ActionController::Parameters#deep_merge by seanpdoyle · Pull Request #45369 · rails/rails
ActionController::Parametersに以下を追加。
#deep_merge#deep_merge!Sean Doyle*
同CHANGELOGより
🔗 Action Pack CHANGELOG(v7.1.0.beta1)
🔗 Remove old raise_on_missing_translations behaviour by ghiculescu · Pull Request #47115 · rails/rails
AbstractController::Translation.raise_on_missing_translationsを削除。これはprivate APIであり、適用範囲の広い
config.i18n.raise_on_missing_translationsに置き換えられた。詳しくはアップグレードガイドを参照。Alex Ghiculescu
同CHANGELOGより
参考: config.i18n.raise_on_missing_translations -- Rails アプリケーションを設定する - Railsガイド
🔗 Add extract_value method to ActionController::Parameters by nvasilevski · Pull Request #49042 · rails/rails
paramsからシリアライズ済みの値を抽出する
ActionController::Parameters#extract_valueメソッドを追加。params = ActionController::Parameters.new(id: "1_123", tags: "ruby,rails") params.extract_value(:id) # => ["1", "123"] params.extract_value(:tags, delimiter: ",") # => ["ruby", "rails"]Nikita Vasilevsky
同CHANGELOGより
参考: 週刊Railsウォッチ20230913: ActionController::Parametersにextract_valueメソッドが追加
🔗 Ensure response.parsed_body support for pattern matching by seanpdoyle · Pull Request #49003 · rails/rails
Parse JSON
response.parsed_bodyでActiveSupport::HashWithIndifferentAccessをサポート。
response.parsed_bodyのJSONコンテンツをActiveSupport::HashWithIndifferentAccessで解析することでパターンマッチング互換とし、Minitestの新しいassert_patternと統合する。Sean Doyle
同CHANGELOGより
参考: 週刊Railsウォッチ20230906: テストのresponse.parsed_bodyでパターンマッチング構文をサポート
🔗 Add support for Playwright as a driver for system tests by yuki24 · Pull Request #48950 · rails/rails
Playwrightをシステムテスト用ドライバとしてサポート。
Yuki Nishijima
同CHANGELOGより
参考: 週刊Railsウォッチ20230906: システムテストでPlaywrightをサポート
🔗 Fix host display when X_FORWARDED_HOST authorized by skipkayhil · Pull Request #48941 · rails/rails
HTTP_HOSTの値によりHostヘッダーがブロックされている場合に、
HostAuthorizationでX_FORWARDED_HOSTの値がX-Forwarded-Hostヘッダーで表示される可能性がある問題を修正。Hartley McGuire, Daniel Schlosser
同CHANGELOGより
参考: これはRails 7.0.8でリリース済みです。
参考: 週刊Railsウォッチ20230906: X_FORWARDED_HOSTの値がヘッダーに表示される可能性があるバグを修正
🔗 Rename fixture_file_upload method to file_fixture_upload by seanpdoyle · Pull Request #48857 · rails/rails
fixture_file_uploadメソッドをfile_fixture_uploadにリネーム。後方互換性のため、
fixture_file_uploadをエイリアスとして宣言した。Sean Doyle
同CHANGELOGより
参考: 週刊Railsウォッチ20230829: Action Packのfixture_file_uploadをfile_fixture_uploadにリネーム
🔗 Save screenshot path on system test failure by matteeyah · Pull Request #48863 · rails/rails
ActionDispatch::SystemTesting::TestHelpers::ScreenshotHelperが、失敗時にスクリーンショットのパスをテストメタデータ内に保存するようになった。Matija Čupić
同CHANGELOGより
参考: 週刊Railsウォッチ20230823: システムテスト失敗時のスクリーンショットのパスをメタデータに保存するようになった
🔗 Introduce config.dom_testing_default_html_version and use Rails::Dom::Testing to parse HTML in test helpers by flavorjones · Pull Request #48682 · rails/rails
ActionDispatch::Assertions#html_documentで使われるHTMLパーサーのバージョンをconfig.dom_testing_default_html_versionコンフィグで制御するようになった。Rails 7.1のデフォルト設定ではHTML5パーサーが選択され(サポートされている場合)、ブラウザのユーザーエージェントでのDOM表示をより正確に表現する。従来、このテストヘルパーは常にNokogiriのHTML4パーサーを利用していた。
Mike Dalessio
同CHANGELOGより
参考: この更新はAction Viewにも含まれています。
参考: 週刊Railsウォッチ20230823: config.dom_testing_default_html_versionが追加
🔗 Create a class level #with_routing helper by andrewn617 · Pull Request #48407 · rails/rails
with_routingヘルパーをクラスレベルで呼び出せるようになった。以下のようにクラスレベルで呼び出される場合、テストごとにルーティングが設定され、テスト後にリセットされる。class RoutingTest < ActionController::TestCase with_routing do |routes| routes.draw do resources :articles resources :authors end end def test_articles_route assert_routing("/articles", controller: "articles", action: "index") end def test_authors_route assert_routing("/authors", controller: "authors", action: "index") end endAndrew Novoselac
同CHANGELOGより
参考: 週刊Railsウォッチ20230628: with_routingヘルパーをクラスレベルで呼び出せるようになった
🔗 improve quoted parameters in mime types by ThunderKey · Pull Request #48397 · rails/rails
Mime::Typeがパラメータ付きMIMEタイプの処理をサポートし、引用符を正しく扱えるようになった。
Acceptヘッダーの解析時に、qパラメータの直前にあるパラメータを保持し、一致するMIMEタイプが存在する場合はこれを利用する。
現在の機能を維持するために、パラメータなしのmedia-typeを探索するフォールバックが作成された。この変更によって、たとえばJSON APIの以下のような複雑なカスタムMIMEタイプを利用できるようになる。
application/vnd.api+json; profile="https://jsonapi.org/profiles/ethanresnick/cursor-pagination/" ext="https://jsonapi.org/ext/atomic"Nicolas Erni
同CHANGELOGより
参考: 週刊Railsウォッチ20230628: 引用符を含むパラメータでのMIMEタイプの扱いを改善した
🔗 Pass params to url_for that ONLY get used for named segments; otherwise discard them by terracatta · Pull Request #43770 · rails/rails
url_forヘルパーでpath_paramsという新しいオプションをサポートするようになった。
これは、ルーティングURLの一部となる必須パラメータを追加したいが、他のルーティングでは余分なクエリパラメータを追加したくない状況で非常に有用。以下のルーティングがあるとする。
Rails.application.routes.draw do scope ":account_id" do get "dashboard" => "pages#dashboard", as: :dashboard get "search/:term" => "search#search", as: :search end delete "signout" => "sessions#destroy", as: :signout end以下の
ApplicationControllerがあるとする。class ApplicationController < ActionController::Base def default_url_options { path_params: { account_id: "foo" } } end end標準の
url_forヘルパー(および類似のヘルパー)の振る舞いは以下のようになる。dashboard_path # => /foo/dashboard dashboard_path(account_id: "bar") # => /bar/dashboard signout_path # => /signout signout_path(account_id: "bar") # => /signout?account_id=bar signout_path(account_id: "bar", path_params: { account_id: "baz" }) # => /signout?account_id=bar search_path("quin") # => /foo/search/quinJason Meller, Jeremy Beker
同CHANGELOGより
参考: 週刊Railsウォッチ20230621: url_forヘルパーに新しいpath_paramsオプションが追加
🔗 Make the test environment show rescuable exceptions in responses by jdufresne · Pull Request #45867 · rails/rails
config.action_dispatch.show_exceptionsに設定可能な値が以下に変更された。
:all:rescuable:none
:allは従来のtrueと同様に振る舞い、:noneは従来のfalseと同様に振る舞う。
新しい:rescuableオプションでは、rescue可能な例外(ActiveRecord::RecordNotFoundなど)のみが表示される。
test環境ではデフォルトで:rescuableが使われるようになった。Jon Dufresne
同CHANGELOGより
参考: 週刊Railsウォッチ20230613: rescue可能な例外をtest環境のエラー画面に表示するようになった
🔗 Support :message_pack as cookies serializer by jonathanhefner · Pull Request #48103 · rails/rails
関連: Support :message_pack as a cache serializer format by jonathanhefner · Pull Request #48104 · rails/rails
関連: Add ActiveSupport::MessagePack by jonathanhefner · Pull Request #47770 · rails/rails
config.action_dispatch.cookies_serializerにシリアライザとして:message_packと:message_pack_allow_marshalを渡せるようになった。これらのシリアライザではmsgpackgem(1.7.0以降)が必要。Message Pack形式では、パフォーマンス向上とペイロードサイズ縮小を提供できる。また、JSONではサポートされていない一部のRuby型のシリアライズ/デシリアライズもサポートしている。
cookies.encrypted[:foo] = [{ a: 1 }, { b: 2 }.with_indifferent_access, 1.to_d, Time.at(0, 123)] # 変更前: config.action_dispatch.cookies_serializer = :json cookies.encrypted[:foo] # => [{"a"=>1}, {"b"=>2}, "1.0", "1969-12-31T18:00:00.000-06:00"] cookies.encrypted[:foo].map(&:class) # => [Hash, Hash, String, String] # 変更後: config.action_dispatch.cookies_serializer = :message_pack cookies.encrypted[:foo] # => [{:a=>1}, {"b"=>2}, 0.1e1, 1969-12-31 18:00:00.000123 -0600] cookies.encrypted[:foo].map(&:class) # => [Hash, ActiveSupport::HashWithIndifferentAccess, BigDecimal, Time]
:message_packシリアライザは、必要に応じてActiveSupport::JSONによるデシリアライズにフォールバック可能。:message_pack_allow_marshalシリアライザも 、MarshalおよびActiveSupport::JSONのどちらでもデシリアライズ可能。さらに、
:marshal、:json、:json_allow_marshal(別名::hybrid) のシリアライザは、必要に応じてデシリアライズをActiveSupport::MessagePackにフォールバック可能。この振る舞いによって古いcookieを読み取り可能になり、移行作業もスムーズになる。Jonathan Hefner
同CHANGELOGより
参考: 週刊Railsウォッチ20230607: cookieシリアライザとメッセージシリアライザでも:message_pack形式をサポート
🔗 Make Rails cookies RFC6265-compliant with domain: :all by gareth · Pull Request #48036 · rails/rails
RFC6265の要件に準拠するため、
domain: :allで設定したcookieのドメイン名から冒頭のドット.を削除。Gareth Adams
同CHANGELOGより
参考: 週刊Railsウォッチ20230524: domain: :allの場合のドメインcookieをRFC6265準拠にした
🔗 Changelog entry for routes source location by luanzeba · Pull Request #47921 · rails/rails
ルーティングの拡張表示にSource Location項目を追加。
$ bin/rails routes --expanded ... --[ Route 14 ]---------- Prefix | new_gist Verb | GET URI | /gist(.:format) Controller#Action | gists/gists#new Source Location | config/routes/gist.rb:3Luan Vieira, John Hawthorn and Daniel Colson
同CHANGELOGより
参考: §6.1 既存のルールを一覧表示する -- Rails のルーティング - Railsガイド
🔗 Alias ActionController::Parameters except as without by hidde-jan · Pull Request #47687 · rails/rails
ActiveController::Parametersのexceptにエイリアスwithoutを追加。Hidde-Jan Jongsma
同CHANGELOGより
参考: 週刊Railsウォッチ20230425: ActionController::Parametersのexceptメソッドにwithoutエイリアスが追加
🔗 Expand rails route search to all table content by jkotchoff · Pull Request #47532 · rails/rails
rails/info/routesの拡張検索フィールドで「ルーティング名」「HTTP Verb」「Controller#Action」も検索可能になった。Jason Kotchoff
同CHANGELOGより
参考: 週刊Railsウォッチ20230328: rails/info/routeページのルーティング検索でテーブルのすべての内容を検索可能にした
🔗 Remove deprecated poltergeist and webkit (capybara-webkit) driver… · rails/rails@696ccbc
非推奨化されていた
poltergeistとwebkit(capybara-webkit)をシステムテスト用のドライバ登録から削除。Rafael Mendonça França
同CHANGELOGより
🔗 Remove deprecated ability to assign a single value to `config.action_… · rails/rails@1e70d0f
config.action_dispatch.trusted_proxiesに単一の値を代入する非推奨化機能を削除。Rafael Mendonça França
同CHANGELOGより
参考: 週刊Railsウォッチ20210330: RemoteIPミドルウェアでtrusted_proxiesに単独の値代入を非推奨化
🔗 Remove deprecated behavior on Request#content_type · rails/rails@689b277
config.action_dispatch.return_only_request_media_type_on_content_typeを非推奨化。Rafael Mendonça França
同CHANGELOGより
Request#content_typeの非推奨化されていた振る舞いを削除。Rafael Mendonça França
同CHANGELOGより
参考: 週刊Railsウォッチ20210201: content_typeメソッドがContent-Typeヘッダーをそのまま返すよう修正
参考: config.action_dispatch.return_only_request_media_type_on_content_type -- Rails アプリケーションを設定する - Railsガイド
🔗 use filtered_path in action_controller event payloads instead of fullpath by ritikesh · Pull Request #47296 · rails/rails
イベントペイロード内で機密情報を含むクエリパラメータをフィルタするため、
ActionController::Instrumentationがfullpathではなくfiltered_pathを渡すように変更した。get "/posts?password=test" request.fullpath # => "/posts?password=test" request.filtered_path # => "/posts?password=[FILTERED]"Ritikesh G
同CHANGELOGより
参考: 週刊Railsウォッチ20230307: Action ControllerのInstrumentation呼び出しでfiltered_pathを使うよう変更
🔗 Deprecate AbstractController MissingHelperError by skipkayhil · Pull Request #47199 · rails/rails
AbstractController::Helpers::MissingHelperErrorを非推奨化。Hartley McGuire
同CHANGELOGより
参考: 週刊Railsウォッチ20230221: AbstractControllerのMissingHelperErrorを非推奨化
🔗 ActionDispatch::Testing::TestResponse#parsed_body parse HTML with Nokogiri by seanpdoyle · Pull Request #47144 · rails/rails
ActionDispatch::Testing::TestResponse#parsed_bodyがHTMLをNokogiriドキュメントとして解析するよう変更。get "/posts" response.content_type # => "text/html; charset=utf-8" response.parsed_body.class # => Nokogiri::HTML5::Document response.parsed_body.to_html # => "<!DOCTYPE html>\n<html>\n..."Sean Doyle
同CHANGELOGより
参考: Rails API parsed_body -- ActionDispatch::TestResponse
🔗 Use Rack's own headers classes where appropriate. by ioquatix · Pull Request #47091 · rails/rails
ActionDispatch::IllegalStateErrorを非推奨化。Samuel Williams
同CHANGELOGより
参考: 週刊Railsウォッチ20230221: 必要な場所ではRack固有のヘッダーを使うよう修正
🔗 Add HTTP::Request#route_uri_pattern that returns URI pattern of matched route. by joelhawksley · Pull Request #47129 · rails/rails
マッチしたルーティングのURIパターンを返す
HTTP::Request#route_uri_patternを追加。Joel Hawksley, Kate Higa
同CHANGELOGより
参考: Rails API route_uri_pattern -- ActionDispatch::Request
🔗 Allow use of SSL-terminating reserve proxy that doesn't set headers by dhh · Pull Request #47139 · rails/rails
ActionDispatch::AssumeSSLミドルウェアを追加。これはconfig.assume_sslでオンにできる。これにより、すべてのリクエストがSSL経由で到着しているとアプリケーションが信じるようになる。これは、SSLを終端するロードバランサーを介してプロキシする場合に、転送されたリクエストがアプリケーションに対してHTTPSではなくHTTPであるかのように表示されるので便利。
これにより、リダイレクトやcookieのセキュリティがHTTPSではなくHTTPを対象とするようになる。このミドルウェアは、実際のリクエストはHTTPSでありながら、サーバーが既にプロキシでSSLを終端したと仮定するようになる。
DHH
同CHANGELOGより
参考: 週刊Railsウォッチ20230214: ActionDispatch::AssumeSSLミドルウェアが追加された
🔗 Only use HostAuthorization if configured by skipkayhil · Pull Request #46858 · rails/rails
config.hostsが空でない場合にのみHostAuthorizationミドルウェアを使うようになった。Hartley McGuire
同CHANGELOGより
参考: 週刊Railsウォッチ20230131: 設定されていないHostAuthorizationミドルウェアを使わないようになった
🔗 Raise error on missing only unless by TooManyBees · Pull Request #43487 · rails/rails
onlyやunlessで既存のメソッドに存在しないシンボルを指定した場合にコールバックでエラーを発生するようになった。
action_nameに応答しないコントローラーでbefore_action :callback, only: :action_nameを宣言すると、リクエスト時に例外を発生するようになった。これは、タイプミスや何かを書き忘れた場合に重要なコールバックを実行できなくならないようにするための安全対策。新しいアプリケーションでは、未定義のアクションに対するエラー発生がデフォルトで有効になっている。この振る舞いを選択したくない場合は、アプリケーションの
config.action_controller.raise_on_missing_callback_actionsコンフィグをfalseに設定する。詳しくは#43487を参照。Jess Bees
同CHANGELOGより
参考: 週刊Railsウォッチ20230131: コールバックのonlyやexceptオプションで指定したシンボルがない場合にエラーにするようになった
参考: 7.1リリース後にこのCHANGELOGのコンフィグ名が修正されました(dec60e5)。
🔗 Dynamic cookie domain per request by braindeaf · Pull Request #46726 · rails/rails
cookieの
options[:domain]にprocを渡せるようになった。これにより、cookieドメインをリクエスト単位で柔軟に設定できる。RobL
同CHANGELOGより
# 同PRより
domain: proc { Tenant.current.cookie_domain } # cookieドメインを動的に設定
domain: proc { |req| ".sub.#{req.host}" }     # cookieドメインをリクエストベースで動的に設定
🔗 Use routes.default_url_options in AC::Renderer env by jonathanhefner · Pull Request #46649 · rails/rails
ActionController::Rendererのenvにホストが指定されていない場合、ホスト関連のオプションがルーティングのdefault_url_optionsとActionDispatch::Http::URL.secure_protocolから導出されるようになった。つまり、アプリケーションが以下のように設定されている場合、
Rails.application.default_url_options = { host: "rubyonrails.org" } Rails.application.config.force_ssl = trueURLを以下のようにレンダリングすると、
ApplicationController.renderer.render inline: "<%= blog_url %>"
"http://example.org/blog"ではなく"https://rubyonrails.org/blog"を返すようになる。Jonathan Hefner
同CHANGELOGより
参考: §4.4 default_url_options -- Action Controller の概要 - Railsガイド
参考: §15 HTTPSプロトコルを強制する -- Action Controller の概要 - Railsガイド
🔗 Add details of cookie name and size to CookieOverflow exception by andyw8 · Pull Request #46570 · rails/rails
CookieOverflow例外の詳細にcookieの名前とサイズを追加。Andy Waite
同CHANGELOGより
🔗 Fix more double logging in ActiveRecord::QueryLogs by ghiculescu · Pull Request #46642 · rails/rails
ActiveRecord::QueryLogを利用中にcontroller、action、namespaced_controllerのログ出力が重複しないようになった。従来は、
config.active_record.query_log_tagsコンフィグに渡す配列に:controllerや:namespaced_controllerや:actionが含まれていると、これらの項目が2回ログ出力されることがあった。
このバグは修正された。Alex Ghiculescu
同CHANGELOGより
参考: この修正はRails 7.0.5でリリース済みです。
🔗 Update permissions policy list by guillaumecabanel · Pull Request #45427 · rails/rails
パーミッションポリシーに以下のディレクティブを追加。
hididle-detectionscreen-wake-lockserialsync-xhrweb-shareGuillaume Cabanel
同CHANGELOGより
参考: 週刊Railsウォッチ20221018: Feature-Policyヘッダーのリストを更新した
🔗 Deprecate obsolete permissions policy directives by jonathanhefner · Pull Request #46199 · rails/rails
パーミッションポリシーで以下のディレクティブを非推奨化した。
speakervibratevrこれらのディレクティブのサポートはブラウザに存在せず、将来サポートされる予定もないので、アプリケーションからこれらのディレクティブを削除するだけでよい。
Jonathan Hefner
同CHANGELOGより
参考: 週刊Railsウォッチ20221018: Feature-Policyヘッダーのリストを更新した
🔗 Allow specifying the HTTP status code in assert_redirected_to by jdufresne · Pull Request #46057 · rails/rails
リダイレクトの正確なHTTP ステータスを指定する
:statusオプションをassert_redirected_toに追加。後方互換性のため、デフォルトは:redirectとなっている。Jon Dufresne
同CHANGELOGより
参考: 週刊Railsウォッチ20221011: assert_redirected_toにHTTPステータスコードも指定可能になった
🔗 ActionDispatch::Cookies json deserializer discards marshal dumps by nbcraft · Pull Request #45956 · rails/rails
注: これはその後#46989で署名済みcookieの場合にマーシャルダンプを破棄するよう更新されています。
CookiesミドルウェアでJSONデシリアライザを
JSON::ParserErrorでrescueしてマーシャルダンプを破棄するようになった。この変更がない場合、
action_dispatch.cookies_serializerに:jsonを設定した状態でアプリケーションが:marshalシリアライズされたcookieを読み取ろうとするとエラーが発生する。このときcookieはクリアされないため、ユーザーはブラウザでcookieを手動でクリアする必要がある。(元のバグに関する議論は#45127を参照)
Nathan Bardoux
同CHANGELOGより
参考: この修正はRails 7.0.5でリリース済みです。
参考: 週刊Railsウォッチ20221003: ActionDispatch::CookiesのJSONデシリアライザのエラーをrescueするよう修正
🔗 Add HTTP_REFERER when following redirects on integration tests by fsateler · Pull Request #40051 · rails/rails
結合テストの
follow_redirect!でHTTP_REFERERを追加。これにより、
follow_redirect!の状況が現実のブラウザに近づく。Felipe Sateler
同CHANGELOGより
参考: Rails API follow_redirect! -- ActionDispatch::Integration::RequestHelpers
🔗 Add exclude? method to ActionController::Parameters by ianneub · Pull Request #45887 · rails/rails
ActionController::Parametersにexclude?メソッドを追加。Ian Neubert
同CHANGELOGより
参考: 週刊Railsウォッチ20221011: exclude?メソッドをActionController::Parametersに追加
🔗 Rescue EOFError error from rack on a multipart request by nvasilevski · Pull Request #45833 · rails/rails
マルチパートリクエストでの
rackのEOFError例外をrescueするようになった。Nikita Vasilevsky
同CHANGELOGより
参考: この修正はRails 7.0.5でリリース済みです。
参考: 週刊Railsウォッチ20220905: マルチパートリクエストでRackのEOFErrorをrescueするよう修正
🔗 Log redirects from router similarly to controller redirects by djfpaagman · Pull Request #43755 · rails/rails
ルーターでのリダイレクトを、コントローラでのリダイレクトと同様にログ出力するようになった。
Dennis Paagman
同CHANGELOGより
参考: 週刊Railsウォッチ20220829: ルーティングで発生するリダイレクトのログ出力を修正
🔗 Prevent ActionDispatch::ServerTiming from overwriting existing header value by jtmalinowski · Pull Request #45615 · rails/rails
ActionDispatch::ServerTimingがServer-Timingで既存の値を上書きしないようになった。従来は、ミドルウェアチェインで別のミドルウェアが
Server-Timingヘッダーを設定した場合にActionDispatch::ServerTimingによって上書きされる可能性があった。Jakub Malinowski
同CHANGELOGより
参考: この修正はRails 7.0.4でリリース済みです
参考: 週刊Railsウォッチ20220725: ActionDispatch::ServerTimingが既存のServer-Timingヘッダーを上書きしないよう修正
🔗 Allow opting out of the SameSite cookie attribute when setting a cookie by ghiculescu · Pull Request #45501 · rails/rails
cookieの設定時に
SameSite属性をオプトアウトできるようになった。以下のように
same_site: nilを渡すことでSameSiteをオプトアウトできる。cookies[:foo] = { value: "bar", same_site: nil }従来は、これを行うと
cookies_same_site_protection設定のSameSite属性が誤った形で設定されていた。Alex Ghiculescu
同CHANGELOGより
参考: 週刊Railsウォッチ20220711: cookieを設定したときにSameSite属性をオプトアウト可能になった
🔗 Fix using helpers in content_security_policy and permissions_policy by ghiculescu · Pull Request #45115 · rails/rails
content_security_policyやpermissions_policyでhelper_methodを利用可能になった。従来は基本的なヘルパー(ヘルパーモジュール内で定義されたもの)は利用可能だったが、
helper_methodで定義されたヘルパーメソッドを利用できなかった。現在は以下のようにどちらも利用可能になった。
content_security_policy do |p| p.default_src "https://example.com" p.script_src "https://example.com" if helpers.script_csp? endAlex Ghiculescu
同CHANGELOGより
🔗 Make behaviour of has_value?/value? more consistent by stefkin · Pull Request #44866 · rails/rails
ActionController::Parametersの#has_value?と#value?を、パラメータとハッシュの比較を避ける形で再実装。パラメータとハッシュの間の非推奨化された等値比較は、Rails 7.2で削除される。
新しい実装は変換に配慮するようになる。Seva Stefkin
同CHANGELOGより
🔗 Only allow String and Symbol keys in ActionController::Parameters by stefkin · Pull Request #44844 · rails/rails
ActionController::ParametersのキーにStringとSymbol以外を使えないようになった。今後は
StringやSymbolでないキーでParametersを初期化するとActionController::InvalidParameterKeyエラーになる。Seva Stefkin
同CHANGELOGより
参考: 週刊Railsウォッチ20220411: ActionController::ParametersのキーにSymbolとStringのみを許可
🔗 Allow CSRF tokens to be stored outside of session. by simbasdad · Pull Request #44283 · rails/rails
CSRFトークンをカスタムロジックでも保存・取得できるようになった。
CSRFトークンは、デフォルトではセッションに保存される。
カスタムクラスを定義することで任意の振る舞いを指定できるが、暗号化cookieに保存する機能については組み込み済み。Andrew Kowpak
同CHANGELOGより
参考: 週刊Railsウォッチ20220411: CSRFトークンをセッションストレージ以外の任意の場所に保存できるようになった
🔗 Don't delegate ActionController::Parameters#values to hash by gmcgibbon · Pull Request #44816 · rails/rails
ActionController::Parameters#valuesが、ネステッドハッシュをParametersにキャストするようになった。Gannon McGibbon
同CHANGELOGより
🔗 Introduce html: and screenshot: kwargs for system test screenshot helper by ghiculescu · Pull Request #44720 · rails/rails
システムテストのスクリーンショットヘルパーにキーワード引数
html:とscreenshot:を追加。既に利用可能な環境変数の代わりにこれらを利用できる。
たとえば、以下はスクリーンショットをiTermに表示し、HTMLを保存してパスを出力する。
take_screenshot(html: true, screenshot: "inline")Alex Ghiculescu
同CHANGELOGより
参考: 週刊Railsウォッチ20220523: システムテストのスクリーンショットヘルパーにhtml:とscreenshot:キーワード引数が追加
🔗 Receive a block to ActionController::Parameters.to_h by bobf · Pull Request #44756 · rails/rails
ActionController::Parameters#to_hにブロックを渡せるようになった。Bob Farrell
同CHANGELOGより
Rails 7: ActionController::Parameters.to_hにブロックを渡せるようになった(翻訳)
🔗 Allow relative redirects when raise_on_open_redirects is enabled by tomhughes · Pull Request #44650 · rails/rails
raise_on_open_redirectsを有効にすることで相対リダイレクトできるようになった。Tom Hughes
同CHANGELOGより
参考: config.action_controller.raise_on_open_redirects -- Rails アプリケーションを設定する - Railsガイド
🔗 Generate content security policy for non-HTML responses by imtayadeway · Pull Request #44635 · rails/rails
APIレスポンスでもContent Security PolicyのDSLを利用可能になった。
Tim Wade
同CHANGELOGより
Content-Security-Policy: default-src 'none'; frame-ancestors 'none'
🔗 Better handle basic authentication without a password by casperisfine · Pull Request #44610 · rails/rails
authenticate_with_http_basicで「パスワードなし」を扱えるよう修正。Rails 7.0より前は、ユーザー名のみを指定するBASIC認証を処理可能だった。
authenticate_with_http_basic do |token, _| ApiClient.authenticate(token) endこの機能が復元された。
Jean Boussier
同CHANGELOGより
参考: Rails API authenticate_with_http_basic -- ActionController::HttpAuthentication::Basic::ControllerMethods
🔗 Apply content security policy mapping when generated dynamically: by Edouard-chin · Pull Request #44578 · rails/rails
content_security_policyが無効なディレクティブを返すことがあったのを修正。ディレクティブが配列を返すlambdaを呼び出した時の結果だった場合、
selfやunsafe-evalなどのディレクティブが一重引用符''で囲まれていなかった。content_security_policy do |policy| policy.frame_ancestors lambda { [:self, "https://example.com"] } endこの修正によって、上で有効なポリシーが生成されるようになった。
Edouard Chin
同CHANGELOGより
参考: この修正はRails 7.0.3でリリース済みです。
参考: 週刊Railsウォッチ20220308: CSPの修正
🔗 Allow skip_forgery_protection if no protection set by brtrick · Pull Request #44537 · rails/rails
フォージェリ保護が有効でない場合や、
verify_authenticity_tokenが定義済みコールバックでない場合でも、skip_forgery_protectionがエラーを発生させずに実行されるよう修正。この修正によって、Rails 7.0の
default_protect_from_forgeryがfalseの場合にWelcomeページ(/)でArgumentErrorが発生しなくなる。Brad Trick
同CHANGELOGより
参考: 週刊Railsウォッチ20220308: skip_forgery_protectionの挙動を修正。
🔗 Remove body content from redirect responses by jdufresne · Pull Request #44554 · rails/rails
redirect_toが空のレスポンスbodyを返すようになった。アプリケーションで
redirect_toの呼び出し後にレスポンスbodyを追加することは引き続き可能。Jon Dufresne
同CHANGELOGより
参考: 週刊Railsウォッチ20220308: リダイレクトのレスポンスからbodyコンテンツを削除
🔗 Stop capturing subdomain in HostAuthorization middleware by sambostock · Pull Request #44520 · rails/rails
ActionDispatch::HostAuthorizationミドルウェアでサブドメインのマッチに使う正規表現のキャプチャグループを非キャプチャグループに変更。サブドメイングループのキャプチャは使われていないので、非キャプチャグループに変えても構わない。
Sam Bostock
同CHANGELOGより
参考: Rails API ActionDispatch::HostAuthorization
🔗 Copy over the IsolatedExecutionState in AC::Live by casperisfine · Pull Request #44499 · rails/rails
ActionController::Liveがエフェメラル(短命な)スレッド内のIsolatedExecutionStateをコピーするよう修正。
ActionController::Liveは導入以来、ミドルウェアで設定されたCurrentAttributesなどがコントローラーアクションで動作するためにスレッドローカルな変数をコピーしていた。Rails 7.0で
IsolatedExecutionStateが導入されたことで、ActionController::Liveコントローラ内にあった一部のグローバルステートが消えた。Jean Boussier
同CHANGELOGより
参考: 週刊Railsウォッチ20220308: ActionContoller::LiveのIsolatedExecutionStateを修正
🔗 Fix setting trailing_slash: true in route definition by casperisfine · Pull Request #44434 · rails/rails
ルーティング定義の
trailing_slash: true設定が効かなくなっていたのを修正。get '/test' => "test#index", as: :test, trailing_slash: true test_path() # => "/test/"Jean Boussier
同CHANGELOGより
参考: 週刊Railsウォッチ20220221: ルーティングのtrailing_slash: trueオプションを修正
🔗 Stringify keys in session.merge! · rails/rails@2bdd29a
Session#merge!のハッシュキーを文字列にした。
Session#updateはそうなっているが、従来のmerge!はそうならなかった。Drew Bragg
同CHANGELOGより
🔗 Content Security Policy: add :unsafe_hashes mapping by Morozzzko · Pull Request #48212 · rails/rails
content_security_policyに:unsafe_hashesマッピングを追加。# 変更前 policy.script_src :strict_dynamic, "'unsafe-hashes'", "'sha256-rRMdkshZyJlCmDX27XnL7g3zXaxv7ei6Sg+yt4R3svU='" # 変更後 policy.script_src :strict_dynamic, :unsafe_hashes, "'sha256-rRMdkshZyJlCmDX27XnL7g3zXaxv7ei6Sg+yt4R3svU='"Igor Morozov
同CHANGELOGより
以前の変更については7-0-stableのCHANGELOGを参照。
関連記事
Rails 7.1に入る主要な機能まとめ(2)error_highlight対応、routes --grepほか(翻訳)
      
概要
MITライセンスに基づいて翻訳・公開いたします。