-
Support
Setvalues in class attributes and token lists.Alexander Senko
-
Implement
button_toin terms ofform_tag.Forms rendered by
button_toinclude[accept-charset="UTF-8"]and render their hidden fields before the button, rather than after it.The
:formoption accepts the options supported byform_tag, such as:multipart.The
:methodoption is case-insensitive, somethod: "DELETE"renders a_methodfield andmethod: "GET"renders aGETform. Verbs other thanGETandPOSTare passed through directly as the_methodfield's value, rather than onlyPATCH,PUT, andDELETE.Sean Doyle
-
Skip attribute names in tag helpers that are blank once converted to a string.
A Symbol such as
:" "is not blank, becauseSymbol#blank?isSymbol#empty?, so it reached the escaping step and produced an attribute with no name. The asset helpers symbolize their keys, so an ordinary String key reached the same place.[GHSA-68p9-83h6-5wpj]
Mike Dalessio
-
Fix
strip_tagsto encode"and'in its output.strip_tagsreturns anhtml_safestring, but was not encoding quotation marks. The method now encodes all five HTML-significant characters (&,<,>,",'), consistent with the existinghtml_safeconvention.Output used outside HTML, such as in a text template or JSON, now contains
"and'where it contained"and'.CGI.unescapeHTMLdecodes them.[GHSA-rq8q-p985-fjq7]
Mike Dalessio
-
Escape the matched phrase before substituting it into
highlight's:highlighter.A match was copied into each
\1of the highlighter as it appeared in the sanitized text, which keeps"and'as they are, so a match containing a quote ended a quoted attribute value such as the documented'<a href="search?q=\1">\1</a>'and added attributes of its own. Each substituted group now goes throughERB::Util.html_escape_once, so quotes in a match render as"and'. Only the numbered placeholders\0to\9are expanded, and a match never replaces the>that closes a tag.[GHSA-v6rj-xm57-3p59]
Jeremy Daer
-
Require rails-html-sanitizer 1.7.2 or later.
With the HTML5 sanitizer, Nokogiri before 1.19.5 left
<and>unescaped in attribute values.highlightandsimple_format, which edit the sanitized HTML as a string, could then turn markup inside an attribute value into live elements. rails-html-sanitizer 1.7.2 requires Loofah 2.25.3, which requires Nokogiri 1.19.5.[GHSA-2p2f-4rq4-gjwc]
Mike Dalessio
-
Percent-encode
<,>, whitespace and control characters in thehrefofLinkheader entries built bypreload_link_tag,stylesheet_link_tagandjavascript_include_tag.A URL containing
>used to close the URI reference early, so the rest of the URL was parsed as extra link parameters or extra links. The HTML tag is unchanged.Richard Desmarais
-
Treat
alpha,headingreset,shadowrootclonable,shadowrootcustomelementregistry,shadowrootdelegatesfocusandshadowrootserializableas boolean attributes in the tag helpers.tag.template(shadowrootmode: "open", shadowrootdelegatesfocus: false)used to rendershadowrootdelegatesfocus="false", which turns the attribute on.falseandnilnow omit these attributes, like the other boolean attributes.Wleeaf
-
Render a string or symbol value of the
hiddenattribute as is, sotag.div(hidden: "until-found")produceshidden="until-found"instead ofhidden="hidden".trueandfalsestill renderhidden="hidden"and no attribute.Wleeaf
-
Fix the debug page for errors raised in view templates on Ruby 4.1.
Ruby 4.1 builds prism into the interpreter as
Ruby::Prism, and error_highlight accepts only its nodes.ActionView::Template#spotnow usesRuby::Prismwhen it is available instead of the prism gem.Yasuo Honda
-
Allow setting
config.action_view.erb_implementationto:herbto compile HTML+ERB templates through Herb.With
config.load_defaults 8.2, templates with the HTML format compile through Herb, an ERB implementation that parses HTML+ERB and reports structural problems, such as an unclosed tag, at compile time with their template location. Valid templates render the same output as with Erubi. All other template formats keep compiling through Erubi.Set
config.action_view.erb_implementationto:erubito continue to compile every template through Erubi.Marco Roth
-
Add a
herb:checkrake task to verify that the application's HTML+ERB templates compile through Herb.The task lists every template Herb rejects with its path and error, and exits with a non-zero status when there are any.
Marco Roth
-
Allow
translate's (andt's)scope:option to be resolved relative to the current template when it starts with a period, mirroring the existing behavior for the key argument.Calling
translate("bar", scope: ".foo")fromposts/index.html.erbis now equivalent to callingtranslate("posts.index.foo.bar").Ben Sheldon
-
Join an
Array:acceptoption with commas infile_field_tag.Previously, passing
accept: ["image/png", "image/gif"]renderedaccept="image/png image/gif", while the HTMLacceptattribute is a comma-separated list. It now rendersaccept="image/png,image/gif", matching the object-basedfile_field.Kenta Ishizaki
-
current_page?matches HTTP QUERY requests RFC 10008) withmethod: :query. The defaultmethod: :getdeliberately does not match QUERY.Jeremy Daer
-
Configuring ERB options is now to be made on the
::ActionView::Baseclass.The
ActionView::Template::Handlers::ERBclass is now private API. Applications that used to configure ERB options such asescape_ignore_listnow need to do this on theActionView::Baseclass or on the railtieconfig.action_viewconfiguration.ActionView::Base.erb_trim_mode = nil ActionView::Base.erb_implementation = ERB ActionView::Base.escape_ignore_list = ["text/csv"] ActionView::Base.strip_trailing_newlines = falseEdouard Chin
-
Fix
search_fieldraisingNameErrorwhen passedautosave: true.Hammad Khan
-
Deprecate registering dependency trackers after application initialization.
Calling
ActionView::DependencyTracker.register_trackerafter application initialization will raise a FrozenError in the next version of Rails.Instead, register trackers during application initialization, wrapped in a call to
ActiveSupport.on_load(:action_view)to wait until Action View is available.Étienne Barrié
-
Extract
current_page?,button_to, andlink_tomethods toActionView::Helpers::NavigationHelperSean Doyle
-
Accept
DateandNumericinputs inrelative_time_in_words.Passing a
Dateor aNumericraisedArgumentErrorinstead of returning a distance string, unlikedistance_of_time_in_wordswhich accepts them.Kenta Ishizaki
-
Support endless and beginless ranges in
number_field_tagandrange_field_tag.Previously, passing an endless (
18..) or beginless (..10) range as the:in/:withinoption raisedRangeError. Now an endless range rendersminwithoutmax, and a beginless range rendersmaxwithoutmin, matchingnumber_fieldandrange_field.Kenta Ishizaki
-
Honor an explicit
value:option incolor_field, includingnil.Previously, passing
value: nilwas ignored and the field still pre-filled from the model's stored color. Now an explicitly providedvalue:is honored, and the stored color is only used when novalue:option is given.Kenta Ishizaki
-
Calling
safe_joinin a view no longer fallbacks to the$,global variable.Previously, calling
safe_joinwould use$,by default to separate elements. Ruby has deprecated the usage of setting$,for more than 10 years and its usage insafe_joinwas never documented.If your application relied on this behaviour, make sure to explicitly pass the separator to
safe_joinas the default is nownil(no separation).Edouard Chin
-
Fix
ActionView::TestCase#renderto resetrendered. The behavior was changed when memoization was added in #51093. Now it once again conforms to the documentation.Jeroen Versteeg
-
Fix
FormBuilder#to_partial_pathreturningnilfor subclasses whose name does not end inBuilder.Kenta Ishizaki
-
Fix
collection_radio_buttonsandcollection_check_boxesgenerating a labelforattribute that does not match the inputidwhen a collection value isnil.Kenta Ishizaki
-
Pass render options and block to calls to
#render_inclass Greeting def render_in(view_context, **) if block_given? view_context.render(html: yield) else view_context.render(inline: <<~ERB.strip, **) Hello <%= local_assigns[:name] || "World" %> ERB end end end render(Greeting.new) # => "Hello, World" render(Greeting.new, name: "Local") # => "Hello, Local" render(renderable: Greeting.new, locals: { name: "Local" }) # => "Hello, Local" render(Greeting.new) { "Hello, Block" } # => "Hello, Block"Sean Doyle
-
Add
f.datalisttoFormBuilderExample:
<%= form_with model: @post do |f| %> <%# Wire the input to the datalist using the same derived id: %> <%= f.text_field :country, list: f.field_id(:country, :datalist) %> <%= f.datalist :country, ["Argentina", "Brazil", "Chile"] %> <% end %> Produces: <input list="post_country_datalist" type="text" name="post[country]" id="post_country" /> <datalist id="post_country_datalist"> <option value="Argentina">Argentina</option> <option value="Brazil">Brazil</option> <option value="Chile">Chile</option> </datalist> *Tahsin Hasan* -
Add
datalist_tagto createdatalistform elements.Example:
datalist_tag('countries_datalist', ['Argentina', ['Brazil', { class: 'brazilian_option' }], ['Chile', 'CL', { disabled: true }]], { class: 'sa-countries-sample' }) #=> <datalist id="countries_datalist" class="sa-countries-sample"> <option value="Argentina">Argentina</option> <option value="Brazil" class="brazilian_option">Brazil</option> <option value="CL" disabled="disabled">Chile</option> </datalist>Willian Gustavo Veiga
-
Render
Hashand keyword options as dasherized HTML attributestag. "POST to /clicked", hx: { post: "/clicked", swap: :outerHTML, data: { json: true } } # => <button hx-post="/clicked" hx-swap="outerHTML" hx-data="{"json":true}">POST to /clicked</button>Sean Doyle
-
ViewReloader#deactivateremoves thefile_system_resolver_hookscallback so forked processes that clear reloaders no longer trigger filesystem scans on everyprepend_view_path.Dave Ariens
-
Defer the View watcher build until view paths are actually registered.
Hugo Vacher
-
Skip blank attribute names in tag helpers to avoid generating invalid HTML.
Mike Dalessio
-
Fix tag parameter content being overwritten instead of combined with tag block content. Before
tag.div("Hello ") { "World" }would just return<div>World</div>, now it returns<div>Hello World</div>.DHH
-
Add ability to pass a block when rendering collection. The block will be executed for each rendered element in the collection.
Vincent Robert
-
Add
key:andexpires_in:options undercached:torenderwhen used withcollection:Jarrett Lusso
Please check8-1-stable for previous changes.