Releases: ViewComponent/view_component
4.12.0
-
Fix stale render context on reused component instances. A
ViewComponent::Baseinstance memoized its controller, helpers, request, view context, lookup context, view flow, and requested format details on first render via||=. Rendering the same instance a second time (intentionally or via aliasing) reused that stale context, which could leak data across requests, sessions, or users.#render_innow resets these ivars on every call so each render derives its context from the current view.Joel Hawksley
-
Fix HTML-safety bypass in
around_render.ViewComponent::Base#around_rendercould return HTML-unsafe strings that bypassed the escaping applied to normal#callreturn values, creating an XSS risk. The vulnerability was amplified inViewComponent::Collection#render_in, which joined per-item results and unconditionally marked the outputhtml_safe. HTML-unsafe strings returned fromaround_renderare now escaped (with a warning) andCollection#render_innow usessafe_joinso unsafe per-item output is escaped instead of laundered into aSafeBuffer.
Joel Hawksley
3.25.0
-
Support Rails
render_inoptions signature. Rails #50623 changed therender_insignature fromrender_in(view_context, &block)torender_in(view_context, **options, &block).ViewComponent::Base#render_in,ViewComponent::Collection#render_in, andViewComponent::Instrumentation#render_innow accept**options, restoring compatibility with Rails main and silencing the deprecation warning.Joel Hawksley
-
Fix stale render context on reused component instances. A
ViewComponent::Baseinstance memoized its controller, helpers, request, view context, lookup context, view flow, and requested format/variant on first render via||=. Rendering the same instance a second time (intentionally or via aliasing) reused that stale context, which could leak data across requests, sessions, or users.#render_innow resets these ivars on every call so each render derives its context from the current view.Joel Hawksley
-
Fix path traversal vulnerability in
ViewComponentsSystemTestControllerwhere sibling directories sharing a string prefix with the allowed temp directory could bypass the path containment check. Thestart_with?check has been replaced with a separator-aware prefix check, and nefarious path errors now return a 404 instead of an unhandled exception.Joel Hawksley
-
Fix preview route vulnerability where inherited methods on
ViewComponent::Preview(such asrender_with_template) could be invoked via the preview URL, allowing arbitrary internal Rails templates to be rendered with attacker-controlled locals and request parameters.render_argsnow raisesAbstractController::ActionNotFoundfor any example not explicitly declared on the preview subclass.Joel Hawksley
4.11.0
-
Update
render_insignature to accept**_for compatibility with Rails #50623.Joel Hawksley
-
Fix translation scope resolution in nested lambda-backed slots. Relative
t(".key")calls inside lambda-backed slots were resolving against an intermediate component's scope instead of the original partial's scope where the block was defined.Artin Boghosian
4.10.0
-
Fix
NameError: uninitialized constant ViewComponent::SystemTestControllerNefariousPathErrorwhen booting in the test environment witheager_load = true.Joel Hawksley
-
Fix yielded content rendered at wrong location when using form helpers.
Joel Hawksley, Markus
4.9.0
-
Fix path traversal vulnerability in
ViewComponentsSystemTestControllerwhere sibling directories sharing a string prefix with the allowed temp directory could bypass the path containment check. Thestart_with?check has been replaced with a separator-aware prefix check, and nefarious path errors now return a 404 instead of an unhandled exception.Joel Hawksley
-
Fix preview route vulnerability where inherited methods on
ViewComponent::Preview(such asrender_with_template) could be invoked via the preview URL, allowing arbitrary internal Rails templates to be rendered with attacker-controlled locals and request parameters.render_argsnow raisesAbstractController::ActionNotFoundfor any example not explicitly declared on the preview subclass.Joel Hawksley
-
Add
yard-lintto CI.Joel Hawksley
4.8.0
-
Add
compile.view_componentActiveSupport::Notifications event for eager compilation at boot time.Joel Hawksley, GitHub Copilot
4.7.0
-
Fix stale content cache when slots are accessed before
render_in.Jared Armstrong
-
Add rubocop-view_component to resources.
Andy Waite
-
Fix bug where inheritance of components with formatless templates improperly raised a NoMethodError.
GitHub Copilot, Joel Hawksley, Cameron Dutro
4.6.0
-
Add
view_identifierto therender.view_componentinstrumentation event payload, containing the path to the component's template file (e.g.app/components/my_component.html.erb). For components using inline render methods,view_identifierwill benil.GitHub Copilot
-
Replace deprecated
require_dependencywithrequirein preview loading.GitHub Copilot
-
Return
html_safeempty string fromrender_inwhenrender?is false.GitHub Copilot
4.5.0
-
Fix initialization ordering issue causing missing asset errors in Sprockets.
Cameron Dutro
4.4.0
-
Fix segfaults when Ruby coverage is enabled.
George Holborn, Joel Hawksley
-
Add
protocolparameter towith_request_urltest helper to enable testing with HTTPS protocol.Joel Hawksley