Module: ActionDispatch::CoreExt::RackMultipartParser
Do not use. This module is for internal use only.
| Relationships & Source Files | |
| Defined in: | actionpack/lib/action_dispatch/core_ext/rack_multipart_parser.rb |
Class Method Summary
Instance Method Summary
- #get_filename(head)
-
#tag_multipart_encoding(filename, content_type, name, body)
This patch is less performant and less reliable than the
::Rack3.1+ version. - #_rails_restrict_encoding(string) private
- #find_encoding private
Class Method Details
.apply
[ GitHub ]# File 'actionpack/lib/action_dispatch/core_ext/rack_multipart_parser.rb', line 6
def self.apply require "rack/multipart" Rack::Multipart::Parser.prepend(self) end
Instance Method Details
#_rails_restrict_encoding(string) (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/core_ext/rack_multipart_parser.rb', line 38
def _rails_restrict_encoding(string) if string.is_a?(String) && !string.frozen? case string.encoding when Encoding::UTF_8, Encoding::BINARY # noop when Encoding::US_ASCII # Might as well tag ASCII as UTF-8 to avoid converstion issues. string.force_encoding(Encoding::UTF_8) else string.force_encoding(Encoding::BINARY) end end string end
#find_encoding (private)
[ GitHub ]# File 'actionpack/lib/action_dispatch/core_ext/rack_multipart_parser.rb', line 12
private def find_encoding(...) case encoding = super when Encoding::UTF_8 encoding when Encoding::US_ASCII Encoding::UTF_8 # Might as well tag ASCII as UTF-8 to avoid converstion issues. else Encoding::BINARY end end
#get_filename(head)
[ GitHub ]# File 'actionpack/lib/action_dispatch/core_ext/rack_multipart_parser.rb', line 33
def get_filename(head) _rails_restrict_encoding(super) end
#tag_multipart_encoding(filename, content_type, name, body)
This patch is less performant and less reliable than the ::Rack 3.1+ version.
# File 'actionpack/lib/action_dispatch/core_ext/rack_multipart_parser.rb', line 24
def tag_multipart_encoding(filename, content_type, name, body) super return if filename _rails_restrict_encoding(name) _rails_restrict_encoding(body) end