Skip to content
  • John Hawthorn's avatar
    c7820d81
    Introduce Template::File as new render file: · c7820d81
    John Hawthorn authored
    The previous behaviour of render file: was essentially the same as
    render template:, except that templates can be specified as an absolute
    path on the filesystem.
    
    This makes sense for historic reasons, but now render file: is almost
    exclusively used to render raw files (not .erb) like public/404.html. In
    addition to complicating the code in template/resolver.rb, I think the
    current behaviour is surprising to developers.
    
    This commit deprecates the existing "lookup a template from anywhere"
    behaviour and replaces it with "render this file exactly as it is on
    disk". Handlers will no longer be used (it will render the same as if
    the :raw handler was used), but formats (.html, .xml, etc) will still be
    detected (and will default to :plain).
    
    The existing render file: behaviour was the path through which Rails
    apps were vulnerable in the recent CVE-2019-5418. Although the
    vulnerability has been patched in a fully backwards-compatible way, I
    think it's a strong hint that we should drop the existing
    previously-vulnerable behaviour if it isn't a benefit to developers.
    c7820d81
    Introduce Template::File as new render file:
    John Hawthorn authored
    The previous behaviour of render file: was essentially the same as
    render template:, except that templates can be specified as an absolute
    path on the filesystem.
    
    This makes sense for historic reasons, but now render file: is almost
    exclusively used to render raw files (not .erb) like public/404.html. In
    addition to complicating the code in template/resolver.rb, I think the
    current behaviour is surprising to developers.
    
    This commit deprecates the existing "lookup a template from anywhere"
    behaviour and replaces it with "render this file exactly as it is on
    disk". Handlers will no longer be used (it will render the same as if
    the :raw handler was used), but formats (.html, .xml, etc) will still be
    detected (and will default to :plain).
    
    The existing render file: behaviour was the path through which Rails
    apps were vulnerable in the recent CVE-2019-5418. Although the
    vulnerability has been patched in a fully backwards-compatible way, I
    think it's a strong hint that we should drop the existing
    previously-vulnerable behaviour if it isn't a benefit to developers.
Loading