Bug #1932
Updated by liaham about 1 year ago
Excerpt from the error and backtrace:
``` ruby
ActionView::Template::Error: <diverse-strings-with-characters> is not a valid MIME type
/path/shared/bundle/ruby/3.1.0/gems/actionpack-6.1.7.6/lib/action_dispatch/http/mime_negotiation.rb:31:in `rescue in block in content_mime_type'
/path/shared/bundle/ruby/3.1.0/gems/actionpack-6.1.7.6/lib/action_dispatch/http/mime_negotiation.rb:24:in `block in content_mime_type'
/path/shared/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/request.rb:69:in `fetch'
/path/shared/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/request.rb:69:in `fetch_header'
/path/shared/bundle/ruby/3.1.0/gems/actionpack-6.1.7.6/lib/action_dispatch/http/mime_negotiation.rb:23:in `content_mime_type'
/path/shared/bundle/ruby/3.1.0/gems/actionpack-6.1.7.6/lib/action_dispatch/http/request.rb:269:in `media_type'
/path/shared/bundle/ruby/3.1.0/gems/actionpack-6.1.7.6/lib/action_dispatch/http/request.rb:355:in `form_data?'
/path/shared/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/request.rb:445:in `POST'
/path/shared/bundle/ruby/3.1.0/gems/actionpack-6.1.7.6/lib/action_dispatch/http/request.rb:400:in `block (2 levels) in POST'
/path/shared/bundle/ruby/3.1.0/gems/actionpack-6.1.7.6/lib/action_dispatch/http/parameters.rb:88:in `parse_formatted_parameters'
/path/shared/bundle/ruby/3.1.0/gems/actionpack-6.1.7.6/lib/action_dispatch/http/request.rb:399:in `block in POST'
/path/shared/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/request.rb:69:in `fetch'
/path/shared/bundle/ruby/3.1.0/gems/rack-2.2.8/lib/rack/request.rb:69:in `fetch_header'
/path/shared/bundle/ruby/3.1.0/gems/actionpack-6.1.7.6/lib/action_dispatch/http/request.rb:398:in `POST'
```
```text
# Examples for <diverse-strings-with-characters>
"%{#context['com.opensymphony.xwork2.dispatcher.httpservletresponse'].addheader('x-tenable'"
"${jndi:ldap://127.0.0.1#log4shell-generic-iV06hYVdJen6hJRK5n3U.w.nessus.org/nessus}"
"%{(#_='multipart/form-data').(#dm=@ognl.ognlcontext@default_member_access).(#_memberaccess?(#_memberaccess=#dm):((#container=#context['com.opensymphony.xwork2.actioncontext.container']).(#ognlutil=#container.getinstance(@com.opensymphony.xwork2.ognl.ognlutil@class)).(#ognlutil.getexcludedpackagenames().clear()).(#ognlutil.getexcludedclasses().clear()).(#context.setmemberaccess(#dm)))).(#iswin=(@java.lang.system@getproperty('os.name').tolowercase().contains('win'))).(#cmds=(#iswin?{'cmd.exe'"
```
Ruby method ` ActionDispatch::Http::MimeNegotiation#content_mime_type`:
``` ruby
# File actionpack/lib/action_dispatch/http/mime_negotiation.rb, line 36
def content_mime_type
fetch_header("action_dispatch.request.content_type") do |k|
v = if get_header("CONTENT_TYPE") =~ /^([^,;]*)/
Mime::Type.lookup($1.strip.downcase)
else
nil
end
set_header k, v
rescue ::Mime::Type::InvalidMimeType => e
raise InvalidType, e.message
end
end
```