Skip to content

Commit 3d809fa

Browse files
authored
Merge pull request #20499 from dwelch-r7/fix-msfconsole-crash-in-pro-install
Add the monkey patch for the TagBuilder that pro needs
2 parents 2896b23 + 672e9fb commit 3d809fa

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

config/application.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,26 @@
44
require 'rails'
55
require File.expand_path('../boot', __FILE__)
66

7+
require 'action_view'
8+
# Monkey patch https://github.com/rails/rails/blob/v7.2.2.1/actionview/lib/action_view/helpers/tag_helper.rb#L51
9+
# Might be fixed by 8.x https://github.com/rails/rails/blob/v8.0.2/actionview/lib/action_view/helpers/tag_helper.rb#L51C1-L52C1
10+
raise unless ActionView::VERSION::STRING == '7.2.2.1' # A developer will need to ensure this is still required when bumping rails
11+
module ActionView::Helpers::TagHelper
12+
class TagBuilder
13+
def self.define_element(name, code_generator:, method_name: name.to_s.underscore)
14+
code_generator.define_cached_method(method_name, namespace: :tag_builder) do |batch|
15+
# Fixing a bug introduced by Metasploit's global Kernel patch: https://github.com/rapid7/metasploit-framework/blob/ae1db09f32cd04c007dbf445cf16dc22c9fc2e53/lib/rex.rb#L74-L79
16+
# which fails when using the below 'instance_methods.include?(method_name.to_sym)' check
17+
batch.push(<<~RUBY) # unless instance_methods.include?(method_name.to_sym)
18+
def #{method_name}(content = nil, escape: true, **options, &block)
19+
tag_string("#{name}", content, options, escape: escape, &block)
20+
end
21+
RUBY
22+
end
23+
end
24+
end
25+
end
26+
727
all_environments = [
828
:development,
929
:production,

0 commit comments

Comments
 (0)