Skip to content

Commit

Permalink
Merge pull request rails#53243 from jhawthorn/erb_loop
Browse files Browse the repository at this point in the history
Fix infinite loop in ERBTracker
  • Loading branch information
jhawthorn authored Oct 9, 2024
2 parents 27e5f71 + 24d1660 commit f1be11a
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
3 changes: 2 additions & 1 deletion actionview/lib/action_view/dependency_tracker/erb_tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,8 @@ def add_static_dependency(dependencies, dependency, quote_type)
wildcard_dependency << scanner.pre_match

while unmatched_brackets > 0 && !scanner.eos?
scanner.scan_until(/[{}]/)
found = scanner.scan_until(/[{}]/)
return unless found

case scanner.matched
when "{"
Expand Down
13 changes: 13 additions & 0 deletions actionview/test/template/dependency_tracker_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,19 @@ def test_dependencies_with_interpolation_non_trailing

assert_equal [ "*/comments" ], tracker.dependencies
end

def test_dependencies_with_interpolation_expr
view_paths = ActionView::PathSet.new([File.expand_path("../fixtures/digestor", __dir__)])

template = FakeTemplate.new(%q{
<%= render "orders/#{variable || "default"}" %>
}, :erb)

tracker = make_tracker("interpolation/_string", template, view_paths)

# unsupported
assert_equal [], tracker.dependencies
end
end

class ERBTrackerTest < ActiveSupport::TestCase
Expand Down

0 comments on commit f1be11a

Please sign in to comment.