Skip to content

Commit 56034c1

Browse files
committed
Merge pull request rails#23242 from maclover7/fix-error-sec
Fix undefined error for `ActionController::Parameters`
1 parent 7921ff8 commit 56034c1

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

actionpack/lib/abstract_controller/rendering.rb

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,10 @@ def view_assigns
7777
# render "foo/bar" to render :file => "foo/bar".
7878
# :api: plugin
7979
def _normalize_args(action=nil, options={})
80-
case action
81-
when ActionController::Parameters
82-
unless action.permitted?
83-
raise ArgumentError, "render parameters are not permitted"
84-
end
80+
if action.respond_to?(:permitted?) && action.permitted?
81+
raise ArgumentError, "render parameters are not permitted"
8582
action
86-
when Hash
83+
elsif action.is_a?(Hash)
8784
action
8885
else
8986
options

actionview/test/template/text_helper_test.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -44,11 +44,11 @@ def test_simple_format
4444
end
4545

4646
def test_simple_format_should_sanitize_input_when_sanitize_option_is_not_false
47-
assert_equal "<p><b> test with unsafe string </b></p>", simple_format("<b> test with unsafe string </b><script>code!</script>")
47+
assert_equal "<p><b> test with unsafe string </b>code!</p>", simple_format("<b> test with unsafe string </b><script>code!</script>")
4848
end
4949

5050
def test_simple_format_should_sanitize_input_when_sanitize_option_is_true
51-
assert_equal '<p><b> test with unsafe string </b></p>',
51+
assert_equal '<p><b> test with unsafe string </b>code!</p>',
5252
simple_format('<b> test with unsafe string </b><script>code!</script>', {}, sanitize: true)
5353
end
5454

@@ -193,7 +193,7 @@ def test_highlight
193193

194194
def test_highlight_should_sanitize_input
195195
assert_equal(
196-
"This is a <mark>beautiful</mark> morning",
196+
"This is a <mark>beautiful</mark> morningcode!",
197197
highlight("This is a beautiful morning<script>code!</script>", "beautiful")
198198
)
199199
end

0 commit comments

Comments
 (0)