1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/actionpack/lib/action_dispatch/http
Carlos Antonio da Silva 618d5317d3 Move the null mime type to request.format
TLDR: always return an object that responds to the query methods from
request.format, and do not touch Mime::Type[] lookup to avoid bugs.

---

Long version:

The initial issue was about being able to do checks like
request.format.html? for request with an unknown format, where
request.format would be nil.

This is where the issue came from at first in #7837 and #8085
(merged in cba05887dc), but the
implementation went down the path of adding this to the mime type
lookup logic.

This unfortunately introduced subtle bugs, for instance in the merged
commit a test related to send_file had to be changed to accomodate the
introduction of the NullType.

Later another bug was found in #13064, related to the content-type being
shown as #<Mime::NullType:...> for templates with localized extensions
but no format included. This one was fixed in #13133, merged in
43962d6ec5.

Besides that, custom handlers were not receiving the proper template
formats anymore when passing through the rendering process, because of
the NullType addition. That was found while migrating an application
from 3.2 to 4.0 that uses the Markerb gem (a custom handler that
generates both text and html emails from a markdown template).

---

This changes the implementation moving away from returning this null
object from the mime lookup, and still fixes the initial issue where
request.format.zomg? would raise an exception for unknown formats due to
request.format being nil.
2013-12-23 16:16:49 -02:00
..
cache.rb drop an unused hash; change slang to SPECIAL 2013-03-19 11:00:01 +05:30
filter_parameters.rb adding missing requires 2013-01-09 15:34:58 -08:00
filter_redirect.rb Adding filter capability to ActionController logs 2012-12-05 11:07:14 +01:00
headers.rb Http::Headers directly modifies the passed environment. 2013-03-15 10:13:49 +01:00
mime_negotiation.rb Move the null mime type to request.format 2013-12-23 16:16:49 -02:00
mime_type.rb Move the null mime type to request.format 2013-12-23 16:16:49 -02:00
mime_types.rb Add Mime::Type.register "text/vcard", :vcf to the default list of mime types 2013-12-05 15:49:06 -08:00
parameter_filter.rb oops, forgot the default parameter 2012-10-18 18:03:09 -07:00
parameters.rb Use each_with_object 2013-08-19 15:23:03 -03:00
rack_cache.rb Deprecate RAILS_CACHE constant. 2012-01-18 01:53:09 +09:00
request.rb Change deep_munge call to avoid deprecation warning 2013-12-03 20:25:03 -02:00
response.rb Remove deprecated cattr_* requires 2013-12-03 00:28:15 +02:00
upload.rb Normalize file parameters in same place as other parameters (ActionDispatch::Http::Parameters#normalize_encode_params) 2013-08-14 21:16:08 -05:00
url.rb Refactor ActionDispatch::Http::URL.build_host_url 2013-04-18 17:12:40 +01:00