actionview 8.1.3.1 → 8.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8aa4ee01b0e607eb916b6fa44ce85dca111d21a89b35d8dcafe7238473dddcc5
4
- data.tar.gz: 3c036732a3611891ba8ac32fb6bf68ccaf7c19c6aaf15f9bc90819744e2aa162
3
+ metadata.gz: bdc26346ea4cdff80ced71eaf5b63f7ab95815f92d4944ca5b554f5dc2092c98
4
+ data.tar.gz: 148985bc4e994851ecef0b9a3cb80fd3e7701b4da44739952797a137863e7148
5
5
  SHA512:
6
- metadata.gz: 157d017bf8051b485efcad2d94c0968e2086db22fdf87ba50764ef45c69265c053fdb441d8f9566c0b089069aa9cb38bc71cb6a54bfdd8ed2d5bf46136957fe2
7
- data.tar.gz: 7a2f125325d636972ded20d7e04d86a25738363db40f1c38c894aa76d8351b209ba8bbeec3ef25c35c93b37121bbd89b194bcc271ee80829d2563ccf5d3b15e0
6
+ metadata.gz: 15f9fac8e9a8deea4e2ee57df40cd968a36c483e4701a3983e0bb078a2bfcbc5b561d20b5c40fb9cc70977489730f2f77fa377d8332df146d74030feb07ff5ac
7
+ data.tar.gz: b40f142e9d6f4597f42f66d2fcb2395e882f2eabcab216ef53c013f0c245e2c6b9e9d8fb5efae7b89b9efd20a1cef6e0611b9574c79035959e14247c99ef0240
data/CHANGELOG.md CHANGED
@@ -1,3 +1,49 @@
1
+ ## Rails 8.1.4 (September 24, 2026) ##
2
+
3
+ * Fix non-ASCII strict locals defaults rendering as mojibake.
4
+
5
+ When a template declared a non-ASCII default in its `locals:` magic comment
6
+ and its body was ASCII-only, the handler returned ASCII-8BIT code and the
7
+ compiled method definition was retagged with it, corrupting the default.
8
+
9
+ *Carlos Daniel Pohlod*
10
+
11
+ * Fix the `:ruby` render tracker not being registered for ERB templates when
12
+ `eager_load` is enabled.
13
+
14
+ *Gabriel Quaresma*
15
+
16
+ * Fix `Encoding::CompatibilityError` when digesting templates with non-ASCII
17
+ content via `DependencyTracker::RubyTracker`.
18
+
19
+ File-backed templates are loaded as ASCII-8BIT. `RubyTracker` now passes
20
+ `template.encode!` to the handler (matching `Template#compiled_source`) so
21
+ handlers such as Haml/Temple can concatenate static UTF-8 strings without
22
+ raising. Fixes #58203.
23
+
24
+ *Edil Talantbek uulu*
25
+
26
+ * Fix `week_field` to not emit invalid week strings at ISO year boundaries.
27
+
28
+ *Kenta Ishizaki*
29
+
30
+ * Fix `ActionView::TestCase#render` to reset `rendered`.
31
+ The behavior was changed when memoization was added in #51093. Now it once again conforms to the documentation.
32
+
33
+ *Jeroen Versteeg*
34
+
35
+ * Fix `FormBuilder#to_partial_path` returning `nil` for subclasses whose
36
+ name does not end in `Builder`.
37
+
38
+ *Kenta Ishizaki*
39
+
40
+ * Fix `collection_radio_buttons` and `collection_check_boxes` generating
41
+ a label `for` attribute that does not match the input `id` when a
42
+ collection value is `nil`.
43
+
44
+ *Kenta Ishizaki*
45
+
46
+
1
47
  ## Rails 8.1.3.1 (July 29, 2026) ##
2
48
 
3
49
  * No changes.
@@ -28,7 +28,7 @@ module ActionView
28
28
  def render_dependencies
29
29
  return [] unless template.source.include?("render")
30
30
 
31
- compiled_source = template.handler.call(template, template.source)
31
+ compiled_source = template.handler.call(template, template.encode!)
32
32
 
33
33
  @parser_class.new(@name, compiled_source).render_calls.filter_map do |render_call|
34
34
  render_call.gsub(%r|/_|, "/")
@@ -9,8 +9,8 @@ module ActionView
9
9
  module VERSION
10
10
  MAJOR = 8
11
11
  MINOR = 1
12
- TINY = 3
13
- PRE = "1"
12
+ TINY = 4
13
+ PRE = nil
14
14
 
15
15
  STRING = [MAJOR, MINOR, TINY, PRE].compact.join(".")
16
16
  end
@@ -1706,7 +1706,7 @@ module ActionView
1706
1706
  end
1707
1707
 
1708
1708
  def self._to_partial_path
1709
- @_to_partial_path ||= name.demodulize.underscore.sub!(/_builder$/, "")
1709
+ @_to_partial_path ||= name.demodulize.underscore.sub(/_builder$/, "")
1710
1710
  end
1711
1711
 
1712
1712
  def to_partial_path
@@ -383,6 +383,11 @@ module ActionView
383
383
  #
384
384
  # select_tag 'person', options_from_collection_for_select(@people, 'id', 'name')
385
385
  #
386
+ # The +value_method+ and +text_method+ can be a method name to call on each member of the +collection+,
387
+ # or a Proc that will be called for each member of the +collection+:
388
+ #
389
+ # options_from_collection_for_select(@people, Proc.new { |person| person.id }, Proc.new { |person| person.name })
390
+ #
386
391
  # If +selected+ is specified as a value or array of values, the element(s) returning a match on +value_method+
387
392
  # will be selected option tag(s).
388
393
  #
@@ -415,14 +420,14 @@ module ActionView
415
420
  #
416
421
  # Parameters:
417
422
  # * +collection+ - An array of objects representing the <tt><optgroup></tt> tags.
418
- # * +group_method+ - The name of a method which, when called on a member of +collection+, returns an
423
+ # * +group_method+ - The name of a method which, when called on a member of +collection+, or a Proc, which when called with a member of +collection+, returns an
419
424
  # array of child objects representing the <tt><option></tt> tags.
420
- # * +group_label_method+ - The name of a method which, when called on a member of +collection+, returns a
425
+ # * +group_label_method+ - The name of a method which, when called on a member of +collection+, or a Proc, which when called with a member of +collection+, returns a
421
426
  # string to be used as the +label+ attribute for its <tt><optgroup></tt> tag.
422
427
  # * +option_key_method+ - The name of a method which, when called on a child object of a member of
423
- # +collection+, returns a value to be used as the +value+ attribute for its <tt><option></tt> tag.
428
+ # +collection+, or a Proc, which when called with a child object of a member of +collection+, returns a value to be used as the +value+ attribute for its <tt><option></tt> tag.
424
429
  # * +option_value_method+ - The name of a method which, when called on a child object of a member of
425
- # +collection+, returns a value to be used as the contents of its <tt><option></tt> tag.
430
+ # +collection+, or a Proc, which when called with a child object of a member of +collection+, returns a value to be used as the contents of its <tt><option></tt> tag.
426
431
  # * +selected_key+ - A value equal to the +value+ attribute for one of the <tt><option></tt> tags,
427
432
  # which will have the +selected+ attribute set. Corresponds to the return value of one of the calls
428
433
  # to +option_key_method+. If +nil+, no selection is made. Can also be a hash if disabled values are
@@ -68,8 +68,18 @@ module ActionView
68
68
  html_options
69
69
  end
70
70
 
71
+ # Sanitize the attribute name used for the label's `for` attribute
72
+ # in collection helpers. When the value is nil or results in an
73
+ # empty sanitized string, skip the trailing underscore to match the
74
+ # id generated by add_default_name_and_id_for_value.
71
75
  def sanitize_attribute_name(value)
72
- "#{sanitized_method_name}_#{sanitized_value(value)}"
76
+ sanitized = sanitized_value(value)
77
+
78
+ if sanitized.empty?
79
+ sanitized_method_name.dup
80
+ else
81
+ "#{sanitized_method_name}_#{sanitized}"
82
+ end
73
83
  end
74
84
 
75
85
  def render_collection
@@ -6,7 +6,7 @@ module ActionView
6
6
  class WeekField < DatetimeField # :nodoc:
7
7
  private
8
8
  def format_datetime(value)
9
- value&.strftime("%Y-W%V")
9
+ value&.strftime("%G-W%V")
10
10
  end
11
11
  end
12
12
  end
@@ -78,10 +78,6 @@ module ActionView
78
78
  end
79
79
 
80
80
  config.after_initialize do |app|
81
- config.after_initialize do
82
- ActionView.render_tracker = config.action_view.render_tracker
83
- end
84
-
85
81
  ActiveSupport.on_load(:action_view) do
86
82
  app.config.action_view.each do |k, v|
87
83
  next if k == :render_tracker
@@ -106,6 +102,10 @@ module ActionView
106
102
  end
107
103
  end
108
104
 
105
+ initializer "action_view.set_render_tracker" do |app|
106
+ ActionView.render_tracker = app.config.action_view.render_tracker
107
+ end
108
+
109
109
  initializer "action_view.setup_action_pack" do |app|
110
110
  ActiveSupport.on_load(:action_controller) do
111
111
  ActionView::RoutingUrlFor.include(ActionDispatch::Routing::UrlFor)
@@ -470,8 +470,9 @@ module ActionView
470
470
  end
471
471
  end_src
472
472
 
473
- # Make sure the source is in the encoding of the returned code
474
- source.force_encoding(code.encoding)
473
+ # Make sure the source is in the encoding of the returned code.
474
+ # ASCII-only code has no encoding worth propagating.
475
+ source.force_encoding(code.encoding) unless code.ascii_only?
475
476
 
476
477
  # In case we get back a String from a handler that is not in
477
478
  # BINARY or the default_internal, encode it to the default_internal
@@ -272,7 +272,7 @@ module ActionView
272
272
  @request = @controller.request
273
273
  @view_flow = ActionView::OutputFlow.new
274
274
  @output_buffer = ActionView::OutputBuffer.new
275
- @rendered = self.class.content_class.new(+"")
275
+ _reset_rendered
276
276
 
277
277
  test_case_instance = self
278
278
  controller_class.define_method(:_test_case) { test_case_instance }
@@ -284,8 +284,18 @@ module ActionView
284
284
 
285
285
  def render(options = {}, local_assigns = {}, &block)
286
286
  view.assign(view_assigns)
287
- @rendered << output = view.render(options, local_assigns, &block)
288
- output
287
+
288
+ if @_rendering
289
+ view.render(options, local_assigns, &block)
290
+ else
291
+ _reset_rendered
292
+ @_rendering = true
293
+ output = view.render(options, local_assigns, &block)
294
+ @rendered << output
295
+ output
296
+ end
297
+ ensure
298
+ @_rendering = false unless @_rendering.nil?
289
299
  end
290
300
 
291
301
  def rendered_views
@@ -383,6 +393,7 @@ module ActionView
383
393
  :@method_name,
384
394
  :@output_buffer,
385
395
  :@_partials,
396
+ :@_rendering,
386
397
  :@passed,
387
398
  :@rendered,
388
399
  :@request,
@@ -412,6 +423,10 @@ module ActionView
412
423
  end]
413
424
  end
414
425
 
426
+ def _reset_rendered
427
+ @rendered = self.class.content_class.new(+"")
428
+ end
429
+
415
430
  def method_missing(selector, ...)
416
431
  begin
417
432
  routes = @controller.respond_to?(:_routes) && @controller._routes
data/lib/action_view.rb CHANGED
@@ -37,6 +37,7 @@ module ActionView
37
37
  eager_autoload do
38
38
  autoload :Base
39
39
  autoload :Context
40
+ autoload :DependencyTracker
40
41
  autoload :Digestor
41
42
  autoload :Helpers
42
43
  autoload :LookupContext
@@ -91,7 +92,19 @@ module ActionView
91
92
  autoload :CacheExpiry
92
93
  autoload :TestCase
93
94
 
94
- singleton_class.attr_accessor :render_tracker
95
+ singleton_class.attr_reader :render_tracker
96
+
97
+ def self.render_tracker=(value)
98
+ @render_tracker = value
99
+ case value
100
+ when :ruby
101
+ DependencyTracker.register_tracker :erb, DependencyTracker::RubyTracker
102
+ else
103
+ DependencyTracker.register_tracker :erb, DependencyTracker::ERBTracker
104
+ end
105
+ value
106
+ end
107
+
95
108
  self.render_tracker = :regex
96
109
 
97
110
  def self.eager_load!
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: actionview
3
3
  version: !ruby/object:Gem::Version
4
- version: 8.1.3.1
4
+ version: 8.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 8.1.3.1
18
+ version: 8.1.4
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 8.1.3.1
25
+ version: 8.1.4
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: builder
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -85,28 +85,28 @@ dependencies:
85
85
  requirements:
86
86
  - - '='
87
87
  - !ruby/object:Gem::Version
88
- version: 8.1.3.1
88
+ version: 8.1.4
89
89
  type: :development
90
90
  prerelease: false
91
91
  version_requirements: !ruby/object:Gem::Requirement
92
92
  requirements:
93
93
  - - '='
94
94
  - !ruby/object:Gem::Version
95
- version: 8.1.3.1
95
+ version: 8.1.4
96
96
  - !ruby/object:Gem::Dependency
97
97
  name: activemodel
98
98
  requirement: !ruby/object:Gem::Requirement
99
99
  requirements:
100
100
  - - '='
101
101
  - !ruby/object:Gem::Version
102
- version: 8.1.3.1
102
+ version: 8.1.4
103
103
  type: :development
104
104
  prerelease: false
105
105
  version_requirements: !ruby/object:Gem::Requirement
106
106
  requirements:
107
107
  - - '='
108
108
  - !ruby/object:Gem::Version
109
- version: 8.1.3.1
109
+ version: 8.1.4
110
110
  description: Simple, battle-tested conventions and helpers for building web pages.
111
111
  email: david@loudthinking.com
112
112
  executables: []
@@ -247,10 +247,10 @@ licenses:
247
247
  - MIT
248
248
  metadata:
249
249
  bug_tracker_uri: https://github.com/rails/rails/issues
250
- changelog_uri: https://github.com/rails/rails/blob/v8.1.3.1/actionview/CHANGELOG.md
251
- documentation_uri: https://api.rubyonrails.org/v8.1.3.1/
250
+ changelog_uri: https://github.com/rails/rails/blob/v8.1.4/actionview/CHANGELOG.md
251
+ documentation_uri: https://api.rubyonrails.org/v8.1.4/
252
252
  mailing_list_uri: https://discuss.rubyonrails.org/c/rubyonrails-talk
253
- source_code_uri: https://github.com/rails/rails/tree/v8.1.3.1/actionview
253
+ source_code_uri: https://github.com/rails/rails/tree/v8.1.4/actionview
254
254
  rubygems_mfa_required: 'true'
255
255
  rdoc_options: []
256
256
  require_paths:
@@ -267,7 +267,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
267
267
  version: '0'
268
268
  requirements:
269
269
  - none
270
- rubygems_version: 4.0.16
270
+ rubygems_version: 4.0.20
271
271
  specification_version: 4
272
272
  summary: Rendering framework putting the V in MVC (part of Rails).
273
273
  test_files: []